-
Notifications
You must be signed in to change notification settings - Fork 97
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
Open
dab246
wants to merge
11
commits into
master
Choose a base branch
from
enhancement/tf-3358-save-draft-locally-periodically
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7123477
TF-3358 Rename `ComposerCache` to `LocalEmailDraft`
dab246 e471829
TF-3358 Save LocalEmailDraft to hive database
dab246 6bfc4e7
TF-3358 Show list draft locally dialog
dab246 7f451e5
TF-3358 Handle `Edit` & `Discard` each local email draft item
dab246 e21a2ec
TF-3358 Handle `Save as draft` each local email draft item
dab246 d1b56e4
TF-3358 Handle `Discard all` local email draft list
dab246 7515dbd
TF-3358 Handle `Restore all` local email draft list
dab246 7f8703f
TF-3358 Auto save draft locally periodically
dab246 815ea74
TF-3358 Remove local email draft when `Delete, Save as draft or Send`…
dab246 1ca994e
TF-3358 Sort list local email draft by time
dab246 02a1b0f
TF-3358 Auto close draft list dialog when click outside
dab246 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
lib/features/base/widget/dialog_builder/dialog_builder_manager.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:core/presentation/extensions/color_extension.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:jmap_dart_client/jmap/account_id.dart'; | ||
import 'package:jmap_dart_client/jmap/core/session/session.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/presentation_local_email_draft.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/local_email_draft/local_email_draft_item_widget.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/local_email_draft/local_email_draft_list_dialog_builder.dart'; | ||
|
||
class DialogBuilderManager { | ||
static final _instance = DialogBuilderManager._(); | ||
|
||
factory DialogBuilderManager() => _instance; | ||
|
||
DialogBuilderManager._(); | ||
|
||
final _isOpened = RxBool(false); | ||
|
||
RxBool get isOpened => _isOpened; | ||
|
||
Future<void> showLocalEmailDraftListDialog({ | ||
required List<PresentationLocalEmailDraft> emailDrafts, | ||
required AccountId? accountId, | ||
required Session? session, | ||
required String ownEmailAddress, | ||
OnEditLocalEmailDraftAction? onEditLocalEmailDraftAction, | ||
OnRestoreAllLocalEmailDraftsAction? onRestoreAllLocalEmailDraftsAction, | ||
}) { | ||
_isOpened.value = true; | ||
return Get.dialog( | ||
LocalEmailDraftListDialogBuilder( | ||
accountId: accountId, | ||
session: session, | ||
ownEmailAddress: ownEmailAddress, | ||
presentationLocalEmailDrafts: emailDrafts, | ||
onEditLocalEmailDraftAction: onEditLocalEmailDraftAction, | ||
onRestoreAllLocalEmailDraftsAction: onRestoreAllLocalEmailDraftsAction, | ||
), | ||
barrierColor: AppColor.colorDefaultCupertinoActionSheet, | ||
).whenComplete(() => _isOpened.value = false); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
lib/features/composer/domain/state/save_local_email_draft_state.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
dab246 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class SaveLocalEmailDraftFailure extends FeatureFailure { | ||
|
||
SaveLocalEmailDraftFailure(dynamic exception) : super(exception: exception); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
lib/features/composer/domain/usecases/save_composer_cache_on_web_interactor.dart
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
lib/features/composer/domain/usecases/save_local_email_draft_interactor.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.