Store and get fcm cache by AccountId
(cherry picked from commit e327dff45a4fc67d0c5a2d2afe64fc4673e2eac1)
This commit is contained in:
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/delete_email_state_to_refresh_state.dart';
|
||||
|
||||
@@ -10,10 +11,10 @@ class DeleteEmailStateToRefreshInteractor {
|
||||
|
||||
DeleteEmailStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(DeleteEmailStateToRefreshLoading());
|
||||
await _fcmRepository.deleteStateToRefresh(TypeName.emailType);
|
||||
await _fcmRepository.deleteStateToRefresh(accountId, TypeName.emailType);
|
||||
yield Right<Failure, Success>(DeleteEmailStateToRefreshSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(DeleteEmailStateToRefreshFailure(e));
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/delete_mailbox_state_to_refresh_state.dart';
|
||||
|
||||
@@ -10,10 +11,10 @@ class DeleteMailboxStateToRefreshInteractor {
|
||||
|
||||
DeleteMailboxStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(DeleteMailboxStateToRefreshLoading());
|
||||
await _fcmRepository.deleteStateToRefresh(TypeName.mailboxType);
|
||||
await _fcmRepository.deleteStateToRefresh(accountId, TypeName.mailboxType);
|
||||
yield Right<Failure, Success>(DeleteMailboxStateToRefreshSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(DeleteMailboxStateToRefreshFailure(e));
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class GetEmailChangesToPushNotificationInteractor {
|
||||
?.map((email) => email.toPresentationEmail())
|
||||
.toList() ?? List.empty();
|
||||
|
||||
yield Right<Failure, Success>(GetEmailChangesToPushNotificationSuccess(presentationEmailList));
|
||||
yield Right<Failure, Success>(GetEmailChangesToPushNotificationSuccess(accountId, presentationEmailList));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetEmailChangesToPushNotificationFailure(e));
|
||||
}
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart';
|
||||
|
||||
@@ -10,10 +11,10 @@ class GetEmailStateToRefreshInteractor {
|
||||
|
||||
GetEmailStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetEmailStateToRefreshLoading());
|
||||
final storedState = await _fcmRepository.getStateToRefresh(TypeName.emailType);
|
||||
final storedState = await _fcmRepository.getStateToRefresh(accountId, TypeName.emailType);
|
||||
yield Right<Failure, Success>(GetEmailStateToRefreshSuccess(storedState));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetEmailStateToRefreshFailure(e));
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart';
|
||||
|
||||
@@ -10,10 +11,10 @@ class GetMailboxStateToRefreshInteractor {
|
||||
|
||||
GetMailboxStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetMailboxStateToRefreshLoading());
|
||||
final storedState = await _fcmRepository.getStateToRefresh(TypeName.mailboxType);
|
||||
final storedState = await _fcmRepository.getStateToRefresh(accountId, TypeName.mailboxType);
|
||||
yield Right<Failure, Success>(GetMailboxStateToRefreshSuccess(storedState));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetMailboxStateToRefreshFailure(e));
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_stored_email_delivery_state.dart';
|
||||
|
||||
@@ -10,10 +11,10 @@ class GetStoredEmailDeliveryStateInteractor {
|
||||
|
||||
GetStoredEmailDeliveryStateInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetStoredEmailDeliveryStateLoading());
|
||||
final storedState = await _fcmRepository.getStateToRefresh(TypeName.emailDelivery);
|
||||
final storedState = await _fcmRepository.getStateToRefresh(accountId, TypeName.emailDelivery);
|
||||
yield Right<Failure, Success>(GetStoredEmailDeliveryStateSuccess(storedState));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetStoredEmailDeliveryStateFailure(e));
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/store_email_delivery_state.dart';
|
||||
@@ -11,10 +12,10 @@ class StoreEmailDeliveryStateInteractor {
|
||||
|
||||
StoreEmailDeliveryStateInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(jmap.State newState) async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, jmap.State newState) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreEmailDeliveryStateLoading());
|
||||
await _fcmRepository.storeStateToRefresh(TypeName.emailDelivery, newState);
|
||||
await _fcmRepository.storeStateToRefresh(accountId, TypeName.emailDelivery, newState);
|
||||
yield Right<Failure, Success>(StoreEmailDeliveryStateSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreEmailDeliveryStateFailure(e));
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/store_email_state_to_refresh_state.dart';
|
||||
@@ -11,10 +12,10 @@ class StoreEmailStateToRefreshInteractor {
|
||||
|
||||
StoreEmailStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(jmap.State newState) async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, jmap.State newState) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreEmailStateToRefreshLoading());
|
||||
await _fcmRepository.storeStateToRefresh(TypeName.emailType, newState);
|
||||
await _fcmRepository.storeStateToRefresh(accountId, TypeName.emailType, newState);
|
||||
yield Right<Failure, Success>(StoreEmailStateToRefreshSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreEmailStateToRefreshFailure(e));
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/store_mailbox_state_to_refresh_state.dart';
|
||||
@@ -11,10 +12,10 @@ class StoreMailboxStateToRefreshInteractor {
|
||||
|
||||
StoreMailboxStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(jmap.State newState) async* {
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, jmap.State newState) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreMailboxStateToRefreshLoading());
|
||||
await _fcmRepository.storeStateToRefresh(TypeName.mailboxType, newState);
|
||||
await _fcmRepository.storeStateToRefresh(accountId, TypeName.mailboxType, newState);
|
||||
yield Right<Failure, Success>(StoreMailboxStateToRefreshSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreMailboxStateToRefreshFailure(e));
|
||||
|
||||
Reference in New Issue
Block a user