TF-297 Store language selected when user changed
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
@@ -13,4 +15,6 @@ abstract class ManageAccountRepository {
|
||||
Future<bool> deleteIdentity(AccountId accountId, IdentityId identityId);
|
||||
|
||||
Future<bool> editIdentity(AccountId accountId, EditIdentityRequest editIdentityRequest);
|
||||
|
||||
Future<void> persistLanguage(Locale localeCurrent);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:core/core.dart';
|
||||
|
||||
class SavingLanguageApp extends UIState {
|
||||
|
||||
SavingLanguageApp();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class SaveLanguageAppSuccess extends UIState {
|
||||
|
||||
SaveLanguageAppSuccess();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class SaveLanguageAppFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
SaveLanguageAppFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'dart:core';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/save_language_app_state.dart';
|
||||
|
||||
class SaveLanguageAppInteractor {
|
||||
final ManageAccountRepository manageAccountRepository;
|
||||
|
||||
SaveLanguageAppInteractor(this.manageAccountRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Locale localeCurrent) async* {
|
||||
try {
|
||||
yield Right(SavingLanguageApp());
|
||||
await manageAccountRepository.persistLanguage(localeCurrent);
|
||||
yield Right(SaveLanguageAppSuccess());
|
||||
} catch (exception) {
|
||||
yield Left(SaveLanguageAppFailure(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user