mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-14 22:12:18 -06:00
Changed saved views handling, changed repository structure with automatic persistence.
This commit is contained in:
@@ -3,25 +3,26 @@ import 'dart:async';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||
import 'package:paperless_mobile/core/repository/state/repository_state.dart';
|
||||
import 'package:paperless_mobile/features/labels/bloc/label_state.dart';
|
||||
|
||||
class LabelCubit<T extends Label> extends Cubit<LabelState<T>> {
|
||||
final LabelRepository<T> _repository;
|
||||
final LabelRepository<T, RepositoryState> _repository;
|
||||
|
||||
late StreamSubscription _subscription;
|
||||
|
||||
LabelCubit(LabelRepository<T> repository)
|
||||
LabelCubit(LabelRepository<T, RepositoryState> repository)
|
||||
: _repository = repository,
|
||||
super(LabelState(
|
||||
isLoaded: repository.isInitialized,
|
||||
labels: repository.current ?? {},
|
||||
labels: repository.current?.values ?? {},
|
||||
)) {
|
||||
_subscription = _repository.values.listen(
|
||||
(update) {
|
||||
if (update == null) {
|
||||
(event) {
|
||||
if (event == null) {
|
||||
emit(LabelState());
|
||||
}
|
||||
emit(LabelState(isLoaded: true, labels: update!));
|
||||
emit(LabelState(isLoaded: true, labels: event!.values));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user