mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-15 10:12:28 -06:00
WIP - more decoupling of blocs
This commit is contained in:
@@ -11,9 +11,13 @@ class LabelCubit<T extends Label> extends Cubit<LabelState<T>> {
|
||||
|
||||
late StreamSubscription _subscription;
|
||||
|
||||
LabelCubit(this._repository) : super(LabelState.initial()) {
|
||||
LabelCubit(LabelRepository<T> repository)
|
||||
: _repository = repository,
|
||||
super(LabelState(labels: repository.current, isLoaded: true)) {
|
||||
_subscription = _repository.labels.listen(
|
||||
(update) => emit(LabelState(isLoaded: true, labels: update)),
|
||||
(update) => emit(
|
||||
LabelState(isLoaded: true, labels: update),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,6 +32,10 @@ class LabelCubit<T extends Label> extends Cubit<LabelState<T>> {
|
||||
return addedItem;
|
||||
}
|
||||
|
||||
Future<void> reload() {
|
||||
return _repository.findAll();
|
||||
}
|
||||
|
||||
Future<T> replace(T item) async {
|
||||
assert(item.id != null);
|
||||
final updatedItem = await _repository.update(item);
|
||||
|
||||
Reference in New Issue
Block a user