feat: Persist label state after get all labels
This commit is contained in:
@@ -6,7 +6,7 @@ import 'package:tmail_ui_user/features/labels/domain/model/edit_label_request.da
|
||||
import 'package:tmail_ui_user/features/labels/domain/model/label_changes_result.dart';
|
||||
|
||||
abstract class LabelRepository {
|
||||
Future<List<Label>> getAllLabels(AccountId accountId);
|
||||
Future<({List<Label> labels, State? newState})> getAllLabels(AccountId accountId);
|
||||
|
||||
Future<Label> createNewLabel(AccountId accountId, Label labelData);
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:labels/model/label.dart';
|
||||
|
||||
class GettingAllLabel extends LoadingState {}
|
||||
|
||||
class GetAllLabelSuccess extends UIState {
|
||||
final List<Label> labels;
|
||||
final State? newState;
|
||||
|
||||
GetAllLabelSuccess(this.labels);
|
||||
GetAllLabelSuccess(this.labels, this.newState);
|
||||
|
||||
@override
|
||||
List<Object> get props => [labels];
|
||||
List<Object?> get props => [labels, newState];
|
||||
}
|
||||
|
||||
class GetAllLabelFailure extends FeatureFailure {
|
||||
|
||||
@@ -13,8 +13,8 @@ class GetAllLabelInteractor {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right(GettingAllLabel());
|
||||
final labels = await _labelRepository.getAllLabels(accountId);
|
||||
yield Right(GetAllLabelSuccess(labels));
|
||||
final result = await _labelRepository.getAllLabels(accountId);
|
||||
yield Right(GetAllLabelSuccess(result.labels, result.newState));
|
||||
} catch (e) {
|
||||
yield Left(GetAllLabelFailure(e));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user