TF-4082 Setup text formatting menu state from user's preferences in composer

This commit is contained in:
dab246
2025-10-02 15:44:22 +07:00
committed by Dat H. Pham
parent 620d155dc3
commit 2e54493a69
17 changed files with 220 additions and 56 deletions
@@ -0,0 +1,17 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
class GettingTextFormattingMenuState extends LoadingState {}
class GetTextFormattingMenuStateSuccess extends UIState {
final bool isDisplayed;
GetTextFormattingMenuStateSuccess(this.isDisplayed);
@override
List<Object?> get props => [isDisplayed];
}
class GetTextFormattingMenuStateFailure extends FeatureFailure {
GetTextFormattingMenuStateFailure(dynamic exception) : super(exception: exception);
}
@@ -0,0 +1,24 @@
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/mailbox_dashboard/domain/state/get_text_formatting_menu_state.dart';
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
class GetTextFormattingMenuStateInteractor {
final ManageAccountRepository _manageAccountRepository;
GetTextFormattingMenuStateInteractor(this._manageAccountRepository);
Stream<Either<Failure, Success>> execute() async* {
try {
yield Right(GettingTextFormattingMenuState());
final preferencesSetting =
await _manageAccountRepository.getLocalSettings();
yield Right(GetTextFormattingMenuStateSuccess(
preferencesSetting.textFormattingMenuConfig.isDisplayed,
));
} catch (exception) {
yield Left(GetTextFormattingMenuStateFailure(exception));
}
}
}
@@ -13,7 +13,7 @@ class RemoveAllComposerCacheOnWebInteractor {
Future<Either<Failure, Success>> execute(AccountId accountId, UserName userName) async {
try {
composerCacheRepository.removeAllComposerCacheOnWeb(accountId, userName);
await composerCacheRepository.removeAllComposerCacheOnWeb(accountId, userName,);
return Right(RemoveComposerCacheSuccess());
} catch (exception) {
return Left(RemoveComposerCacheFailure(exception));
@@ -17,7 +17,7 @@ class RemoveComposerCacheByIdOnWebInteractor {
String composerId,
) async {
try {
composerCacheRepository.removeComposerCacheByIdOnWeb(
await composerCacheRepository.removeComposerCacheByIdOnWeb(
accountId,
userName,
composerId,