TF-2871 Block notification on folders Sent, Outbox, Drafts, Spam and Trash
This commit is contained in:
@@ -48,11 +48,11 @@ class AuthorizationInterceptors extends QueuedInterceptorsWrapper {
|
||||
_token = newToken;
|
||||
_configOIDC = newConfig;
|
||||
_authenticationType = AuthenticationType.oidc;
|
||||
log('AuthorizationInterceptors::setTokenAndAuthorityOidc: TokenId = ${newToken?.tokenIdHash}');
|
||||
log('AuthorizationInterceptors::setTokenAndAuthorityOidc: INITIAL_TOKEN = ${newToken?.token} | EXPIRED_TIME = ${newToken?.expiredTime}');
|
||||
}
|
||||
|
||||
void _updateNewToken(TokenOIDC newToken) {
|
||||
log('AuthorizationInterceptors::_updateNewToken: TokenId = ${newToken.tokenIdHash}');
|
||||
log('AuthorizationInterceptors::_updateNewToken: NEW_TOKEN = ${newToken.token} | EXPIRED_TIME = ${newToken.expiredTime}');
|
||||
_token = newToken;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,15 @@ class UpdateAccountCacheSuccess extends UIState {
|
||||
}
|
||||
|
||||
class UpdateAccountCacheFailure extends FeatureFailure {
|
||||
final Session session;
|
||||
final String apiUrl;
|
||||
|
||||
UpdateAccountCacheFailure(dynamic exception) : super(exception: exception);
|
||||
UpdateAccountCacheFailure({
|
||||
required this.session,
|
||||
required this.apiUrl,
|
||||
dynamic exception,
|
||||
}) : super(exception: exception);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [session, apiUrl, ...super.props];
|
||||
}
|
||||
@@ -1,39 +1,26 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:model/account/authentication_type.dart';
|
||||
import 'package:model/account/personal_account.dart';
|
||||
import 'package:model/extensions/personal_account_extension.dart';
|
||||
import 'package:model/extensions/session_extension.dart';
|
||||
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/update_authentication_account_state.dart';
|
||||
|
||||
class UpdateAccountCacheInteractor {
|
||||
final AccountRepository _accountRepository;
|
||||
final CredentialRepository _credentialRepository;
|
||||
|
||||
UpdateAccountCacheInteractor(
|
||||
this._accountRepository,
|
||||
this._credentialRepository);
|
||||
UpdateAccountCacheInteractor(this._accountRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Session session) async* {
|
||||
Stream<Either<Failure, Success>> execute({required Session session, String? baseUrl}) async* {
|
||||
final apiUrl = _getQualifiedApiUrl(session: session, baseUrl: baseUrl);
|
||||
log('UpdateAccountCacheInteractor::execute: ApiUrl = $apiUrl');
|
||||
try{
|
||||
yield Right(UpdatingAccountCache());
|
||||
|
||||
final futureValue = await Future.wait([
|
||||
_credentialRepository.getBaseUrl(),
|
||||
_accountRepository.getCurrentAccount(),
|
||||
], eagerError: true);
|
||||
|
||||
final baseUrl = futureValue[0] as Uri;
|
||||
final currentAccount = futureValue[1] as PersonalAccount;
|
||||
final apiUrl = session.getQualifiedApiUrl(
|
||||
baseUrl: currentAccount.authenticationType == AuthenticationType.basic
|
||||
? baseUrl.origin
|
||||
: baseUrl.toString());
|
||||
final currentAccount = await _accountRepository.getCurrentAccount();
|
||||
|
||||
await _accountRepository.setCurrentAccount(
|
||||
currentAccount.fromAccount(
|
||||
@@ -46,7 +33,20 @@ class UpdateAccountCacheInteractor {
|
||||
session: session,
|
||||
apiUrl: apiUrl));
|
||||
} catch(e) {
|
||||
yield Left(UpdateAccountCacheFailure(e));
|
||||
yield Left(UpdateAccountCacheFailure(
|
||||
session: session,
|
||||
apiUrl: apiUrl,
|
||||
exception: e
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
String _getQualifiedApiUrl({required Session session, String? baseUrl}) {
|
||||
try {
|
||||
return session.getQualifiedApiUrl(baseUrl: baseUrl);
|
||||
} catch (e) {
|
||||
logError('UpdateAccountCacheInteractor::_getQualifiedApiUrl:Exception = $e');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user