Fix missing notification when execute receive new email & mark as read at same time in terminated app
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
|
|
||||||
class GetSessionLoading extends LoadingState {}
|
class GetSessionLoading extends LoadingState {}
|
||||||
|
|
||||||
class GetSessionSuccess extends UIState {
|
class GetSessionSuccess extends UIState {
|
||||||
final Session session;
|
final Session session;
|
||||||
|
final StateChange? stateChange;
|
||||||
|
|
||||||
GetSessionSuccess(this.session);
|
GetSessionSuccess(this.session, {this.stateChange});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [session];
|
List<Object?> get props => [session, stateChange];
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetSessionFailure extends FeatureFailure {
|
class GetSessionFailure extends FeatureFailure {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:core/presentation/state/success.dart';
|
|||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:core/utils/platform_info.dart';
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
import 'package:tmail_ui_user/features/home/domain/repository/session_repository.dart';
|
import 'package:tmail_ui_user/features/home/domain/repository/session_repository.dart';
|
||||||
import 'package:tmail_ui_user/features/home/domain/state/get_session_state.dart';
|
import 'package:tmail_ui_user/features/home/domain/state/get_session_state.dart';
|
||||||
|
|
||||||
@@ -11,26 +12,29 @@ class GetSessionInteractor {
|
|||||||
|
|
||||||
GetSessionInteractor(this.sessionRepository);
|
GetSessionInteractor(this.sessionRepository);
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> execute() async* {
|
Stream<Either<Failure, Success>> execute({StateChange? stateChange}) async* {
|
||||||
try {
|
try {
|
||||||
yield Right<Failure, Success>(GetSessionLoading());
|
yield Right<Failure, Success>(GetSessionLoading());
|
||||||
final session = await sessionRepository.getSession();
|
final session = await sessionRepository.getSession();
|
||||||
yield Right<Failure, Success>(GetSessionSuccess(session));
|
yield Right<Failure, Success>(GetSessionSuccess(session, stateChange: stateChange));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (PlatformInfo.isMobile) {
|
if (PlatformInfo.isMobile) {
|
||||||
yield* _getStoredSessionFromCache(remoteException: e);
|
yield* _getStoredSessionFromCache(remoteException: e, stateChange: stateChange);
|
||||||
} else {
|
} else {
|
||||||
yield Left<Failure, Success>(GetSessionFailure(e));
|
yield Left<Failure, Success>(GetSessionFailure(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> _getStoredSessionFromCache({dynamic remoteException}) async* {
|
Stream<Either<Failure, Success>> _getStoredSessionFromCache({
|
||||||
|
dynamic remoteException,
|
||||||
|
StateChange? stateChange
|
||||||
|
}) async* {
|
||||||
try {
|
try {
|
||||||
log('GetSessionInteractor::_getStoredSessionFromCache:remoteException: $remoteException');
|
log('GetSessionInteractor::_getStoredSessionFromCache:remoteException: $remoteException');
|
||||||
yield Right<Failure, Success>(GetSessionLoading());
|
yield Right<Failure, Success>(GetSessionLoading());
|
||||||
final session = await sessionRepository.getStoredSession();
|
final session = await sessionRepository.getStoredSession();
|
||||||
yield Right<Failure, Success>(GetSessionSuccess(session));
|
yield Right<Failure, Success>(GetSessionSuccess(session, stateChange: stateChange));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield Left<Failure, Success>(GetSessionFailure(remoteException ?? e));
|
yield Left<Failure, Success>(GetSessionFailure(remoteException ?? e));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
import 'package:model/account/password.dart';
|
import 'package:model/account/password.dart';
|
||||||
|
import 'package:model/account/personal_account.dart';
|
||||||
|
|
||||||
class GetCredentialViewState extends UIState {
|
class GetCredentialViewState extends UIState {
|
||||||
final Uri baseUrl;
|
final Uri baseUrl;
|
||||||
final UserName userName;
|
final UserName userName;
|
||||||
final Password password;
|
final Password password;
|
||||||
|
final PersonalAccount personalAccount;
|
||||||
|
final StateChange? stateChange;
|
||||||
|
|
||||||
GetCredentialViewState(this.baseUrl, this.userName, this.password);
|
GetCredentialViewState(
|
||||||
|
this.baseUrl,
|
||||||
|
this.userName,
|
||||||
|
this.password,
|
||||||
|
this.personalAccount,
|
||||||
|
{this.stateChange});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [baseUrl, userName, password];
|
List<Object?> get props => [
|
||||||
|
baseUrl,
|
||||||
|
userName,
|
||||||
|
password,
|
||||||
|
personalAccount,
|
||||||
|
stateChange];
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetCredentialFailure extends FeatureFailure {
|
class GetCredentialFailure extends FeatureFailure {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
|
import 'package:model/account/personal_account.dart';
|
||||||
import 'package:model/oidc/oidc_configuration.dart';
|
import 'package:model/oidc/oidc_configuration.dart';
|
||||||
import 'package:model/oidc/token_oidc.dart';
|
import 'package:model/oidc/token_oidc.dart';
|
||||||
|
|
||||||
@@ -7,11 +9,24 @@ class GetStoredTokenOidcSuccess extends UIState {
|
|||||||
final Uri baseUrl;
|
final Uri baseUrl;
|
||||||
final TokenOIDC tokenOidc;
|
final TokenOIDC tokenOidc;
|
||||||
final OIDCConfiguration oidcConfiguration;
|
final OIDCConfiguration oidcConfiguration;
|
||||||
|
final PersonalAccount personalAccount;
|
||||||
|
final StateChange? stateChange;
|
||||||
|
|
||||||
GetStoredTokenOidcSuccess(this.baseUrl, this.tokenOidc, this.oidcConfiguration);
|
GetStoredTokenOidcSuccess(
|
||||||
|
this.baseUrl,
|
||||||
|
this.tokenOidc,
|
||||||
|
this.oidcConfiguration,
|
||||||
|
this.personalAccount,
|
||||||
|
{this.stateChange}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [baseUrl, tokenOidc, oidcConfiguration];
|
List<Object?> get props => [
|
||||||
|
baseUrl,
|
||||||
|
tokenOidc,
|
||||||
|
oidcConfiguration,
|
||||||
|
personalAccount,
|
||||||
|
stateChange];
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetStoredTokenOidcFailure extends FeatureFailure {
|
class GetStoredTokenOidcFailure extends FeatureFailure {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
import 'package:model/account/authentication_type.dart';
|
import 'package:model/account/authentication_type.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/repository/account_repository.dart';
|
import 'package:tmail_ui_user/features/login/domain/repository/account_repository.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
||||||
@@ -18,15 +19,19 @@ class GetAuthenticatedAccountInteractor {
|
|||||||
this._getStoredTokenOidcInteractor
|
this._getStoredTokenOidcInteractor
|
||||||
);
|
);
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> execute() async* {
|
Stream<Either<Failure, Success>> execute({StateChange? stateChange}) async* {
|
||||||
try {
|
try {
|
||||||
yield Right<Failure, Success>(LoadingState());
|
yield Right<Failure, Success>(LoadingState());
|
||||||
final account = await _accountRepository.getCurrentAccount();
|
final account = await _accountRepository.getCurrentAccount();
|
||||||
yield Right(GetAuthenticatedAccountSuccess(account));
|
yield Right(GetAuthenticatedAccountSuccess(account));
|
||||||
if (account.authenticationType == AuthenticationType.oidc) {
|
if (account.authenticationType == AuthenticationType.oidc) {
|
||||||
yield* _getStoredTokenOidcInteractor.execute(account.id);
|
yield* _getStoredTokenOidcInteractor.execute(
|
||||||
|
personalAccount: account,
|
||||||
|
stateChange: stateChange);
|
||||||
} else {
|
} else {
|
||||||
yield await _getCredentialInteractor.execute();
|
yield await _getCredentialInteractor.execute(
|
||||||
|
personalAccount: account,
|
||||||
|
stateChange: stateChange);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield Left(GetAuthenticatedAccountFailure(e));
|
yield Left(GetAuthenticatedAccountFailure(e));
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import 'package:core/presentation/state/failure.dart';
|
|||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
import 'package:model/account/password.dart';
|
import 'package:model/account/password.dart';
|
||||||
|
import 'package:model/account/personal_account.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/extensions/uri_extension.dart';
|
import 'package:tmail_ui_user/features/login/domain/extensions/uri_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||||
@@ -15,7 +17,10 @@ class GetCredentialInteractor {
|
|||||||
|
|
||||||
GetCredentialInteractor(this.credentialRepository);
|
GetCredentialInteractor(this.credentialRepository);
|
||||||
|
|
||||||
Future<Either<Failure, Success>> execute() async {
|
Future<Either<Failure, Success>> execute({
|
||||||
|
required PersonalAccount personalAccount,
|
||||||
|
StateChange? stateChange
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
final baseUrl = await credentialRepository.getBaseUrl();
|
final baseUrl = await credentialRepository.getBaseUrl();
|
||||||
final authenticationInfo = await credentialRepository.getAuthenticationInfoStored();
|
final authenticationInfo = await credentialRepository.getAuthenticationInfoStored();
|
||||||
@@ -23,7 +28,9 @@ class GetCredentialInteractor {
|
|||||||
return Right(GetCredentialViewState(
|
return Right(GetCredentialViewState(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
UserName(authenticationInfo.username),
|
UserName(authenticationInfo.username),
|
||||||
Password(authenticationInfo.password)));
|
Password(authenticationInfo.password),
|
||||||
|
personalAccount,
|
||||||
|
stateChange: stateChange));
|
||||||
} else {
|
} else {
|
||||||
return Left(GetCredentialFailure(BadCredentials()));
|
return Left(GetCredentialFailure(BadCredentials()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'package:core/presentation/state/failure.dart';
|
|||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
|
import 'package:model/account/personal_account.dart';
|
||||||
import 'package:model/oidc/oidc_configuration.dart';
|
import 'package:model/oidc/oidc_configuration.dart';
|
||||||
import 'package:model/oidc/token_oidc.dart';
|
import 'package:model/oidc/token_oidc.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||||
@@ -16,13 +18,15 @@ class GetStoredTokenOidcInteractor {
|
|||||||
|
|
||||||
GetStoredTokenOidcInteractor(this._authenticationOIDCRepository, this._credentialRepository);
|
GetStoredTokenOidcInteractor(this._authenticationOIDCRepository, this._credentialRepository);
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> execute(String tokenIdHash) async* {
|
Stream<Either<Failure, Success>> execute({
|
||||||
|
required PersonalAccount personalAccount,
|
||||||
|
StateChange? stateChange
|
||||||
|
}) async* {
|
||||||
try {
|
try {
|
||||||
log('GetStoredTokenOidcInteractor::execute(): tokenIdHash: $tokenIdHash');
|
|
||||||
yield Right<Failure, Success>(LoadingState());
|
yield Right<Failure, Success>(LoadingState());
|
||||||
final futureValue = await Future.wait([
|
final futureValue = await Future.wait([
|
||||||
_credentialRepository.getBaseUrl(),
|
_credentialRepository.getBaseUrl(),
|
||||||
_authenticationOIDCRepository.getStoredTokenOIDC(tokenIdHash),
|
_authenticationOIDCRepository.getStoredTokenOIDC(personalAccount.id),
|
||||||
_authenticationOIDCRepository.getStoredOidcConfiguration(),
|
_authenticationOIDCRepository.getStoredOidcConfiguration(),
|
||||||
], eagerError: true);
|
], eagerError: true);
|
||||||
|
|
||||||
@@ -33,7 +37,12 @@ class GetStoredTokenOidcInteractor {
|
|||||||
log('GetStoredTokenOidcInteractor::execute(): oidcConfiguration: $oidcConfiguration');
|
log('GetStoredTokenOidcInteractor::execute(): oidcConfiguration: $oidcConfiguration');
|
||||||
|
|
||||||
if (_isCredentialValid(baseUrl)) {
|
if (_isCredentialValid(baseUrl)) {
|
||||||
yield Right(GetStoredTokenOidcSuccess(baseUrl, tokenOidc, oidcConfiguration));
|
yield Right(GetStoredTokenOidcSuccess(
|
||||||
|
baseUrl,
|
||||||
|
tokenOidc,
|
||||||
|
oidcConfiguration,
|
||||||
|
personalAccount,
|
||||||
|
stateChange: stateChange));
|
||||||
} else {
|
} else {
|
||||||
yield Left(GetStoredTokenOidcFailure(InvalidBaseUrl()));
|
yield Left(GetStoredTokenOidcFailure(InvalidBaseUrl()));
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-60
@@ -13,6 +13,7 @@ import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
|||||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
import 'package:jmap_dart_client/jmap/push/state_change.dart';
|
||||||
|
import 'package:model/model.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
import 'package:rxdart/rxdart.dart';
|
||||||
import 'package:tmail_ui_user/features/base/action/ui_action.dart';
|
import 'package:tmail_ui_user/features/base/action/ui_action.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
||||||
@@ -21,7 +22,6 @@ import 'package:tmail_ui_user/features/home/domain/state/get_session_state.dart'
|
|||||||
import 'package:tmail_ui_user/features/home/domain/usecases/get_session_interactor.dart';
|
import 'package:tmail_ui_user/features/home/domain/usecases/get_session_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/home/presentation/home_bindings.dart';
|
import 'package:tmail_ui_user/features/home/presentation/home_bindings.dart';
|
||||||
import 'package:tmail_ui_user/features/login/data/network/interceptors/authorization_interceptors.dart';
|
import 'package:tmail_ui_user/features/login/data/network/interceptors/authorization_interceptors.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_stored_token_oidc_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_stored_token_oidc_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
||||||
@@ -43,7 +43,6 @@ class FcmMessageController extends FcmBaseController {
|
|||||||
AccountId? _currentAccountId;
|
AccountId? _currentAccountId;
|
||||||
Session? _currentSession;
|
Session? _currentSession;
|
||||||
UserName? _userName;
|
UserName? _userName;
|
||||||
Map<String, dynamic>? _payloadData;
|
|
||||||
|
|
||||||
GetAuthenticatedAccountInteractor? _getAuthenticatedAccountInteractor;
|
GetAuthenticatedAccountInteractor? _getAuthenticatedAccountInteractor;
|
||||||
DynamicUrlInterceptors? _dynamicUrlInterceptors;
|
DynamicUrlInterceptors? _dynamicUrlInterceptors;
|
||||||
@@ -90,21 +89,21 @@ class FcmMessageController extends FcmBaseController {
|
|||||||
void _handleForegroundMessageAction(Map<String, dynamic> payloadData) {
|
void _handleForegroundMessageAction(Map<String, dynamic> payloadData) {
|
||||||
log('FcmMessageController::_handleForegroundMessageAction():payloadData: $payloadData | _currentAccountId: $_currentAccountId');
|
log('FcmMessageController::_handleForegroundMessageAction():payloadData: $payloadData | _currentAccountId: $_currentAccountId');
|
||||||
if (_currentAccountId != null && _userName != null) {
|
if (_currentAccountId != null && _userName != null) {
|
||||||
final stateChange = _parsingPayloadData(payloadData);
|
final stateChange = FcmUtils.instance.convertFirebaseDataMessageToStateChange(payloadData);
|
||||||
final mapTypeState = stateChange.getMapTypeState(_currentAccountId!);
|
final mapTypeState = stateChange.getMapTypeState(_currentAccountId!);
|
||||||
_mappingTypeStateToAction(mapTypeState, _currentAccountId!, _userName!, session: _currentSession);
|
_mappingTypeStateToAction(
|
||||||
|
mapTypeState,
|
||||||
|
_currentAccountId!,
|
||||||
|
_userName!,
|
||||||
|
session: _currentSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleBackgroundMessageAction(Map<String, dynamic> payloadData) async {
|
void _handleBackgroundMessageAction(Map<String, dynamic> payloadData) async {
|
||||||
log('FcmMessageController::_handleBackgroundMessageAction():payloadData: $payloadData');
|
log('FcmMessageController::_handleBackgroundMessageAction():payloadData: $payloadData');
|
||||||
_payloadData = payloadData;
|
final stateChange = FcmUtils.instance.convertFirebaseDataMessageToStateChange(payloadData);
|
||||||
await _initialAppConfig();
|
await _initialAppConfig();
|
||||||
_getAuthenticatedAccount();
|
_getAuthenticatedAccount(stateChange: stateChange);
|
||||||
}
|
|
||||||
|
|
||||||
StateChange? _parsingPayloadData(Map<String, dynamic> payloadData) {
|
|
||||||
return FcmUtils.instance.convertFirebaseDataMessageToStateChange(payloadData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _mappingTypeStateToAction(
|
void _mappingTypeStateToAction(
|
||||||
@@ -199,26 +198,13 @@ class FcmMessageController extends FcmBaseController {
|
|||||||
FcmTokenController.instance.initialBindingInteractor();
|
FcmTokenController.instance.initialBindingInteractor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getAuthenticatedAccount() {
|
void _getAuthenticatedAccount({StateChange? stateChange}) {
|
||||||
if (_getAuthenticatedAccountInteractor != null) {
|
if (_getAuthenticatedAccountInteractor != null) {
|
||||||
consumeState(_getAuthenticatedAccountInteractor!.execute());
|
consumeState(_getAuthenticatedAccountInteractor!.execute(stateChange: stateChange));
|
||||||
} else {
|
|
||||||
_clearPayloadData();
|
|
||||||
logError('FcmMessageController::_getAuthenticatedAccount():_getAuthenticatedAccountInteractor is null');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleGetAuthenticatedAccountSuccess(GetAuthenticatedAccountSuccess success) {
|
|
||||||
_currentAccountId = success.account.accountId;
|
|
||||||
_userName = success.account.userName;
|
|
||||||
if (!PlatformInfo.isAndroid) {
|
|
||||||
_dynamicUrlInterceptors?.changeBaseUrl(success.account.apiUrl);
|
|
||||||
}
|
|
||||||
log('FcmMessageController::_handleGetAuthenticatedAccountSuccess():_currentAccountId: $_currentAccountId | _userName: $_userName');
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleGetAccountByOidcSuccess(GetStoredTokenOidcSuccess storedTokenOidcSuccess) {
|
void _handleGetAccountByOidcSuccess(GetStoredTokenOidcSuccess storedTokenOidcSuccess) {
|
||||||
log('FcmMessageController::_handleGetAccountByOidcSuccess():');
|
|
||||||
_dynamicUrlInterceptors?.setJmapUrl(storedTokenOidcSuccess.baseUrl.toString());
|
_dynamicUrlInterceptors?.setJmapUrl(storedTokenOidcSuccess.baseUrl.toString());
|
||||||
_authorizationInterceptors?.setTokenAndAuthorityOidc(
|
_authorizationInterceptors?.setTokenAndAuthorityOidc(
|
||||||
newToken: storedTokenOidcSuccess.tokenOidc,
|
newToken: storedTokenOidcSuccess.tokenOidc,
|
||||||
@@ -227,14 +213,24 @@ class FcmMessageController extends FcmBaseController {
|
|||||||
|
|
||||||
if (PlatformInfo.isAndroid) {
|
if (PlatformInfo.isAndroid) {
|
||||||
_dynamicUrlInterceptors?.changeBaseUrl(storedTokenOidcSuccess.baseUrl.toString());
|
_dynamicUrlInterceptors?.changeBaseUrl(storedTokenOidcSuccess.baseUrl.toString());
|
||||||
_getSessionAction();
|
_getSessionAction(stateChange: storedTokenOidcSuccess.stateChange);
|
||||||
} else {
|
} else {
|
||||||
_pushActionFromRemoteMessageBackground();
|
_dynamicUrlInterceptors?.changeBaseUrl(storedTokenOidcSuccess.personalAccount.apiUrl);
|
||||||
|
|
||||||
|
final accountId = storedTokenOidcSuccess.personalAccount.accountId;
|
||||||
|
final username = storedTokenOidcSuccess.personalAccount.userName;
|
||||||
|
final stateChange = storedTokenOidcSuccess.stateChange;
|
||||||
|
|
||||||
|
if (accountId != null && username != null && stateChange != null) {
|
||||||
|
_pushActionFromRemoteMessageBackground(
|
||||||
|
accountId: accountId,
|
||||||
|
userName: username,
|
||||||
|
stateChange: stateChange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleGetAccountByBasicAuthSuccess(GetCredentialViewState credentialViewState) {
|
void _handleGetAccountByBasicAuthSuccess(GetCredentialViewState credentialViewState) {
|
||||||
log('FcmMessageController::_handleGetAccountByBasicAuthSuccess():');
|
|
||||||
_dynamicUrlInterceptors?.setJmapUrl(credentialViewState.baseUrl.toString());
|
_dynamicUrlInterceptors?.setJmapUrl(credentialViewState.baseUrl.toString());
|
||||||
_authorizationInterceptors?.setBasicAuthorization(
|
_authorizationInterceptors?.setBasicAuthorization(
|
||||||
credentialViewState.userName,
|
credentialViewState.userName,
|
||||||
@@ -242,61 +238,73 @@ class FcmMessageController extends FcmBaseController {
|
|||||||
);
|
);
|
||||||
if (PlatformInfo.isAndroid) {
|
if (PlatformInfo.isAndroid) {
|
||||||
_dynamicUrlInterceptors?.changeBaseUrl(credentialViewState.baseUrl.toString());
|
_dynamicUrlInterceptors?.changeBaseUrl(credentialViewState.baseUrl.toString());
|
||||||
_getSessionAction();
|
_getSessionAction(stateChange: credentialViewState.stateChange);
|
||||||
} else {
|
} else {
|
||||||
_pushActionFromRemoteMessageBackground();
|
_dynamicUrlInterceptors?.changeBaseUrl(credentialViewState.personalAccount.apiUrl);
|
||||||
|
|
||||||
|
final accountId = credentialViewState.personalAccount.accountId;
|
||||||
|
final username = credentialViewState.personalAccount.userName;
|
||||||
|
final stateChange = credentialViewState.stateChange;
|
||||||
|
|
||||||
|
if (accountId != null && username != null && stateChange != null) {
|
||||||
|
_pushActionFromRemoteMessageBackground(
|
||||||
|
accountId: accountId,
|
||||||
|
userName: username,
|
||||||
|
stateChange: stateChange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getSessionAction() {
|
void _getSessionAction({StateChange? stateChange}) {
|
||||||
if (_getSessionInteractor != null) {
|
if (_getSessionInteractor != null) {
|
||||||
consumeState(_getSessionInteractor!.execute());
|
consumeState(_getSessionInteractor!.execute(stateChange: stateChange));
|
||||||
} else {
|
|
||||||
_clearPayloadData();
|
|
||||||
logError('FcmMessageController::_getSessionAction():_getSessionInteractor is null');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleGetSessionSuccess(GetSessionSuccess success) {
|
void _handleGetSessionSuccess(GetSessionSuccess success) {
|
||||||
_currentSession = success.session;
|
try {
|
||||||
_userName = success.session.username;
|
final apiUrl = success.session.getQualifiedApiUrl(baseUrl: _dynamicUrlInterceptors?.jmapUrl);
|
||||||
final apiUrl = success.session.getQualifiedApiUrl(baseUrl: _dynamicUrlInterceptors?.jmapUrl);
|
final stateChange = success.stateChange;
|
||||||
log('FcmMessageController::_pushActionFromRemoteMessageBackground():apiUrl: $apiUrl');
|
|
||||||
if (apiUrl.isNotEmpty) {
|
if (apiUrl.isNotEmpty && stateChange != null) {
|
||||||
_dynamicUrlInterceptors?.changeBaseUrl(apiUrl);
|
_dynamicUrlInterceptors?.changeBaseUrl(apiUrl);
|
||||||
_pushActionFromRemoteMessageBackground();
|
|
||||||
} else {
|
_pushActionFromRemoteMessageBackground(
|
||||||
_clearPayloadData();
|
accountId: success.session.personalAccount.accountId,
|
||||||
logError('FcmMessageController::_handleGetSessionSuccess():apiUrl is null');
|
userName: success.session.username,
|
||||||
|
stateChange: stateChange,
|
||||||
|
session: success.session);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logError('FcmMessageController::_handleGetSessionSuccess: Exception $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushActionFromRemoteMessageBackground() {
|
void _pushActionFromRemoteMessageBackground({
|
||||||
log('FcmMessageController::_pushActionFromRemoteMessageBackground():_payloadData: $_payloadData | _currentAccountId: $_currentAccountId | _currentSession: $_currentSession');
|
required AccountId accountId,
|
||||||
if (_payloadData?.isNotEmpty == true && _currentAccountId != null && _userName != null) {
|
required UserName userName,
|
||||||
final stateChange = _parsingPayloadData(_payloadData!);
|
required StateChange stateChange,
|
||||||
final mapTypeState = stateChange.getMapTypeState(_currentAccountId!);
|
Session? session
|
||||||
_mappingTypeStateToAction(mapTypeState, _currentAccountId!, _userName!, isForeground: false, session: _currentSession);
|
}) {
|
||||||
}
|
final mapTypeState = stateChange.getMapTypeState(accountId);
|
||||||
_clearPayloadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _clearPayloadData() {
|
_mappingTypeStateToAction(
|
||||||
_payloadData = null;
|
mapTypeState,
|
||||||
|
accountId,
|
||||||
|
userName,
|
||||||
|
isForeground: false,
|
||||||
|
session: session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleFailureViewState(Failure failure) {
|
void handleFailureViewState(Failure failure) {
|
||||||
log('FcmMessageController::_handleFailureViewState(): $failure');
|
log('FcmMessageController::_handleFailureViewState(): $failure');
|
||||||
_clearPayloadData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleSuccessViewState(Success success) {
|
void handleSuccessViewState(Success success) {
|
||||||
log('FcmMessageController::_handleSuccessViewState(): $success');
|
log('FcmMessageController::_handleSuccessViewState(): $success');
|
||||||
if (success is GetAuthenticatedAccountSuccess) {
|
if (success is GetSessionSuccess) {
|
||||||
_handleGetAuthenticatedAccountSuccess(success);
|
|
||||||
} else if (success is GetSessionSuccess) {
|
|
||||||
_handleGetSessionSuccess(success);
|
_handleGetSessionSuccess(success);
|
||||||
} else if (success is GetStoredTokenOidcSuccess) {
|
} else if (success is GetStoredTokenOidcSuccess) {
|
||||||
_handleGetAccountByOidcSuccess(success);
|
_handleGetAccountByOidcSuccess(success);
|
||||||
|
|||||||
Reference in New Issue
Block a user