-
Notifications
You must be signed in to change notification settings - Fork 86
TF-3358 Save draft locally periodically #3598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2745462
52a8505
afca9e7
75d8213
ff65f7d
53a3cce
a7311d8
7d94fba
4a5c529
1582106
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart'; | ||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/local_email_draft.dart'; | ||
|
||
class LocalEmailDraftClient extends HiveCacheClient<LocalEmailDraft> { | ||
|
||
@override | ||
String get tableName => CachingConstants.localDraftEmailCacheBoxName; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:core/presentation/state/failure.dart'; | ||
import 'package:core/presentation/state/success.dart'; | ||
|
||
class SaveLocalEmailDraftSuccess extends UIState {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, we should keep the id of which local email was saved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use it for anything right now, so keeping it at this point is unnecessary. |
||
|
||
class SaveLocalEmailDraftFailure extends FeatureFailure { | ||
|
||
SaveLocalEmailDraftFailure(dynamic exception) : super(exception: exception); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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/account_id.dart'; | ||
import 'package:jmap_dart_client/jmap/core/user_name.dart'; | ||
import 'package:tmail_ui_user/features/composer/domain/repository/composer_repository.dart'; | ||
import 'package:tmail_ui_user/features/composer/domain/state/save_local_email_draft_state.dart'; | ||
import 'package:tmail_ui_user/features/composer/presentation/extensions/create_email_request_extension.dart'; | ||
import 'package:tmail_ui_user/features/composer/presentation/model/create_email_request.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/local_email_draft_repository.dart'; | ||
|
||
class SaveLocalEmailDraftInteractor { | ||
final LocalEmailDraftRepository _localEmailDraftRepository; | ||
final ComposerRepository _composerRepository; | ||
|
||
SaveLocalEmailDraftInteractor( | ||
this._localEmailDraftRepository, | ||
this._composerRepository, | ||
); | ||
|
||
Future<Either<Failure, Success>> execute( | ||
CreateEmailRequest createEmailRequest, | ||
AccountId accountId, | ||
UserName userName, | ||
) async { | ||
try { | ||
final emailCreated = await _composerRepository.generateEmail( | ||
createEmailRequest, | ||
withIdentityHeader: true, | ||
isDraft: true, | ||
); | ||
await _localEmailDraftRepository.saveLocalEmailDraft( | ||
createEmailRequest.generateLocalEmailDraftFromEmail( | ||
email: emailCreated, | ||
accountId: accountId, | ||
userName: userName, | ||
), | ||
); | ||
return Right(SaveLocalEmailDraftSuccess()); | ||
} catch (exception) { | ||
return Left(SaveLocalEmailDraftFailure(exception)); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please dont forget to upgrade hiveDBVersion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a new box to the hive database does not require a version upgrade. A version upgrade is only required when changing the data structure of an existing box.