mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-15 18:12:26 -06:00
WIP - Redesigned login flow
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||
@@ -13,11 +12,17 @@ class LabelCubit<T extends Label> extends Cubit<LabelState<T>> {
|
||||
|
||||
LabelCubit(LabelRepository<T> repository)
|
||||
: _repository = repository,
|
||||
super(LabelState(labels: repository.current, isLoaded: true)) {
|
||||
_subscription = _repository.labels.listen(
|
||||
(update) => emit(
|
||||
LabelState(isLoaded: true, labels: update),
|
||||
),
|
||||
super(LabelState(
|
||||
isLoaded: repository.isInitialized,
|
||||
labels: repository.current ?? {},
|
||||
)) {
|
||||
_subscription = _repository.values.listen(
|
||||
(update) {
|
||||
if (update == null) {
|
||||
emit(LabelState());
|
||||
}
|
||||
emit(LabelState(isLoaded: true, labels: update!));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ class LabelState<T extends Label> {
|
||||
final Map<int, T> labels;
|
||||
|
||||
LabelState({
|
||||
required this.isLoaded,
|
||||
required this.labels,
|
||||
this.isLoaded = false,
|
||||
this.labels = const {},
|
||||
});
|
||||
|
||||
T? getLabel(int? key) {
|
||||
|
||||
Reference in New Issue
Block a user