Fix missing notification when execute receive new email & mark as read at same time in terminated app
This commit is contained in:
@@ -1,17 +1,31 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.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/personal_account.dart';
|
||||
|
||||
class GetCredentialViewState extends UIState {
|
||||
final Uri baseUrl;
|
||||
final UserName userName;
|
||||
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
|
||||
List<Object> get props => [baseUrl, userName, password];
|
||||
List<Object?> get props => [
|
||||
baseUrl,
|
||||
userName,
|
||||
password,
|
||||
personalAccount,
|
||||
stateChange];
|
||||
}
|
||||
|
||||
class GetCredentialFailure extends FeatureFailure {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:core/presentation/state/failure.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/token_oidc.dart';
|
||||
|
||||
@@ -7,11 +9,24 @@ class GetStoredTokenOidcSuccess extends UIState {
|
||||
final Uri baseUrl;
|
||||
final TokenOIDC tokenOidc;
|
||||
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
|
||||
List<Object?> get props => [baseUrl, tokenOidc, oidcConfiguration];
|
||||
List<Object?> get props => [
|
||||
baseUrl,
|
||||
tokenOidc,
|
||||
oidcConfiguration,
|
||||
personalAccount,
|
||||
stateChange];
|
||||
}
|
||||
|
||||
class GetStoredTokenOidcFailure extends FeatureFailure {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.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:tmail_ui_user/features/login/domain/repository/account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
||||
@@ -18,15 +19,19 @@ class GetAuthenticatedAccountInteractor {
|
||||
this._getStoredTokenOidcInteractor
|
||||
);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
Stream<Either<Failure, Success>> execute({StateChange? stateChange}) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
final account = await _accountRepository.getCurrentAccount();
|
||||
yield Right(GetAuthenticatedAccountSuccess(account));
|
||||
if (account.authenticationType == AuthenticationType.oidc) {
|
||||
yield* _getStoredTokenOidcInteractor.execute(account.id);
|
||||
yield* _getStoredTokenOidcInteractor.execute(
|
||||
personalAccount: account,
|
||||
stateChange: stateChange);
|
||||
} else {
|
||||
yield await _getCredentialInteractor.execute();
|
||||
yield await _getCredentialInteractor.execute(
|
||||
personalAccount: account,
|
||||
stateChange: stateChange);
|
||||
}
|
||||
} catch (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:dartz/dartz.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/personal_account.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/repository/credential_repository.dart';
|
||||
@@ -15,7 +17,10 @@ class GetCredentialInteractor {
|
||||
|
||||
GetCredentialInteractor(this.credentialRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute() async {
|
||||
Future<Either<Failure, Success>> execute({
|
||||
required PersonalAccount personalAccount,
|
||||
StateChange? stateChange
|
||||
}) async {
|
||||
try {
|
||||
final baseUrl = await credentialRepository.getBaseUrl();
|
||||
final authenticationInfo = await credentialRepository.getAuthenticationInfoStored();
|
||||
@@ -23,7 +28,9 @@ class GetCredentialInteractor {
|
||||
return Right(GetCredentialViewState(
|
||||
baseUrl,
|
||||
UserName(authenticationInfo.username),
|
||||
Password(authenticationInfo.password)));
|
||||
Password(authenticationInfo.password),
|
||||
personalAccount,
|
||||
stateChange: stateChange));
|
||||
} else {
|
||||
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/utils/app_logger.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/token_oidc.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||
@@ -16,13 +18,15 @@ class GetStoredTokenOidcInteractor {
|
||||
|
||||
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 {
|
||||
log('GetStoredTokenOidcInteractor::execute(): tokenIdHash: $tokenIdHash');
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
final futureValue = await Future.wait([
|
||||
_credentialRepository.getBaseUrl(),
|
||||
_authenticationOIDCRepository.getStoredTokenOIDC(tokenIdHash),
|
||||
_authenticationOIDCRepository.getStoredTokenOIDC(personalAccount.id),
|
||||
_authenticationOIDCRepository.getStoredOidcConfiguration(),
|
||||
], eagerError: true);
|
||||
|
||||
@@ -33,7 +37,12 @@ class GetStoredTokenOidcInteractor {
|
||||
log('GetStoredTokenOidcInteractor::execute(): oidcConfiguration: $oidcConfiguration');
|
||||
|
||||
if (_isCredentialValid(baseUrl)) {
|
||||
yield Right(GetStoredTokenOidcSuccess(baseUrl, tokenOidc, oidcConfiguration));
|
||||
yield Right(GetStoredTokenOidcSuccess(
|
||||
baseUrl,
|
||||
tokenOidc,
|
||||
oidcConfiguration,
|
||||
personalAccount,
|
||||
stateChange: stateChange));
|
||||
} else {
|
||||
yield Left(GetStoredTokenOidcFailure(InvalidBaseUrl()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user