mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-15 02:12:25 -06:00
Cleaned up code, implemented message queue to notify subscribers of document updates.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user