mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 08:08:14 -06:00
fix: Refactor labels structure
This commit is contained in:
@@ -23,8 +23,8 @@ class DocumentChangedNotifier {
|
||||
_deleted.add(deleted);
|
||||
}
|
||||
|
||||
void subscribe(
|
||||
dynamic subscriber, {
|
||||
void addListener(
|
||||
Object subscriber, {
|
||||
DocumentChangedCallback? onUpdated,
|
||||
DocumentChangedCallback? onDeleted,
|
||||
}) {
|
||||
@@ -41,7 +41,7 @@ class DocumentChangedNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
void unsubscribe(dynamic subscriber) {
|
||||
void removeListener(Object subscriber) {
|
||||
_subscribers[subscriber]?.forEach((element) {
|
||||
element.cancel();
|
||||
});
|
||||
|
||||
@@ -8,7 +8,9 @@ class LabelRepository extends HydratedCubit<LabelRepositoryState> {
|
||||
final PaperlessLabelsApi _api;
|
||||
final Map<Object, StreamSubscription> _subscribers = {};
|
||||
|
||||
void subscribe(
|
||||
LabelRepository(this._api) : super(const LabelRepositoryState());
|
||||
|
||||
void addListener(
|
||||
Object source, {
|
||||
required void Function(LabelRepositoryState) onChanged,
|
||||
}) {
|
||||
@@ -18,12 +20,19 @@ class LabelRepository extends HydratedCubit<LabelRepositoryState> {
|
||||
});
|
||||
}
|
||||
|
||||
void unsubscribe(Object source) async {
|
||||
void removeListener(Object source) async {
|
||||
await _subscribers[source]?.cancel();
|
||||
_subscribers.remove(source);
|
||||
}
|
||||
|
||||
LabelRepository(this._api) : super(const LabelRepositoryState());
|
||||
Future<void> initialize() {
|
||||
return Future.wait([
|
||||
findAllCorrespondents(),
|
||||
findAllDocumentTypes(),
|
||||
findAllStoragePaths(),
|
||||
findAllTags(),
|
||||
]);
|
||||
}
|
||||
|
||||
Future<Tag> createTag(Tag object) async {
|
||||
final created = await _api.saveTag(object);
|
||||
|
||||
Reference in New Issue
Block a user