Cleaned up code, implemented message queue to notify subscribers of document updates.

This commit is contained in:
Anton Stubenbord
2023-02-06 01:04:13 +01:00
parent 337c178be8
commit 4d7fab1839
111 changed files with 1412 additions and 1029 deletions

View File

@@ -11,12 +11,27 @@ class LinkedDocumentsCubit extends Cubit<LinkedDocumentsState>
@override
final DocumentChangedNotifier notifier;
LinkedDocumentsCubit(
this.api,
DocumentFilter filter,
this.api,
this.notifier,
) : super(const LinkedDocumentsState()) {
updateFilter(filter: filter);
notifier.subscribe(
this,
onUpdated: replace,
onDeleted: remove,
);
}
@override
Future<void> update(DocumentModel document) async {
final updated = await api.update(document);
if (!state.filter.matches(updated)) {
remove(document);
} else {
replace(document);
}
}
}