diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json index 696f41ef..60c80324 100644 --- a/Wino.Core.Domain/Translations/en_US/resources.json +++ b/Wino.Core.Domain/Translations/en_US/resources.json @@ -112,6 +112,7 @@ "DiscordChannelDisclaimerMessage": "Wino doesn't have it's own Discord server, but special 'wino-mail' channel is hosted at 'Developer Sanctuary' server.\nTo get the updates about Wino please join Developer Sanctuary server and follow 'wino-mail' channel under 'Community Projects'\n\nYou will be directed to server URL since Discord doesn't support channel invites.", "DiscordChannelDisclaimerTitle": "Important Discord Information", "Draft": "Draft", + "Busy": "Busy", "EditorToolbarOption_Draw": "Draw", "EditorToolbarOption_Format": "Format", "EditorToolbarOption_Insert": "Insert", @@ -123,6 +124,7 @@ "ElementTheme_Light": "Light mode", "Emoji": "Emoji", "Exception_WinoServerException": "Wino server failed.", + "Exception_MailProcessing": "This mail is still being processed. Please try again after few seconds.", "Exception_ImapAutoDiscoveryFailed": "Couldn't find mailbox settings.", "Exception_ImapClientPoolFailed": "IMAP Client Pool failed.", "Exception_AuthenticationCanceled": "Authentication canceled", diff --git a/Wino.Core.Domain/Translator.Designer.cs b/Wino.Core.Domain/Translator.Designer.cs index e37aedff..f3d42df0 100644 --- a/Wino.Core.Domain/Translator.Designer.cs +++ b/Wino.Core.Domain/Translator.Designer.cs @@ -583,6 +583,11 @@ namespace Wino.Core.Domain /// public static string Draft => Resources.GetTranslatedString(@"Draft"); + /// + /// Busy + /// + public static string Busy => Resources.GetTranslatedString(@"Busy"); + /// /// Draw /// @@ -638,6 +643,11 @@ namespace Wino.Core.Domain /// public static string Exception_WinoServerException => Resources.GetTranslatedString(@"Exception_WinoServerException"); + /// + /// This mail is still being processed. Please try again after few seconds. + /// + public static string Exception_MailProcessing => Resources.GetTranslatedString(@"Exception_MailProcessing"); + /// /// Couldn't find mailbox settings. /// diff --git a/Wino.Mail.ViewModels/ComposePageViewModel.cs b/Wino.Mail.ViewModels/ComposePageViewModel.cs index d3424bf5..051672b1 100644 --- a/Wino.Mail.ViewModels/ComposePageViewModel.cs +++ b/Wino.Mail.ViewModels/ComposePageViewModel.cs @@ -8,7 +8,6 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; using MimeKit; -using MimeKit.Utils; using Wino.Core.Domain; using Wino.Core.Domain.Entities; using Wino.Core.Domain.Enums; @@ -21,6 +20,7 @@ using Wino.Core.Extensions; using Wino.Core.Services; using Wino.Mail.ViewModels.Data; using Wino.Messaging.Client.Mails; +using Wino.Messaging.Server; namespace Wino.Mail.ViewModels { @@ -112,6 +112,7 @@ namespace Wino.Mail.ViewModels private readonly IWinoRequestDelegator _worker; public readonly IFontService FontService; public readonly IPreferencesService PreferencesService; + private readonly IWinoServerConnectionManager _winoServerConnectionManager; public readonly IContactService ContactService; public ComposePageViewModel(IDialogService dialogService, @@ -124,7 +125,8 @@ namespace Wino.Mail.ViewModels IWinoRequestDelegator worker, IContactService contactService, IFontService fontService, - IPreferencesService preferencesService) : base(dialogService) + IPreferencesService preferencesService, + IWinoServerConnectionManager winoServerConnectionManager) : base(dialogService) { NativeAppService = nativeAppService; _folderService = folderService; @@ -139,6 +141,7 @@ namespace Wino.Mail.ViewModels SelectedToolbarSection = ToolbarSections[0]; PreferencesService = preferencesService; + _winoServerConnectionManager = winoServerConnectionManager; } [RelayCommand] @@ -297,24 +300,6 @@ namespace Wino.Mail.ViewModels ToItems.CollectionChanged -= ContactListCollectionChanged; ToItems.CollectionChanged += ContactListCollectionChanged; - - // Check if there is any delivering mail address from protocol launch. - - if (_launchProtocolService.MailToUri != null) - { - // TODO - //var requestedMailContact = await GetAddressInformationAsync(_launchProtocolService.MailtoParameters, ToItems); - - //if (requestedMailContact != null) - //{ - // ToItems.Add(requestedMailContact); - //} - //else - // DialogService.InfoBarMessage("Invalid Address", "Address is not a valid e-mail address.", InfoBarMessageType.Warning); - - // Clear the address. - _launchProtocolService.MailToUri = null; - } } private void ContactListCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) @@ -375,6 +360,8 @@ namespace Wino.Mail.ViewModels return; } + retry: + // Replying existing message. MimeMessageInformation mimeMessageInformation = null; @@ -386,18 +373,24 @@ namespace Wino.Mail.ViewModels { if (downloadIfNeeded) { - // TODO: Folder id needs to be passed. - // TODO: Send mail retrieve request. - // _worker.Queue(new FetchSingleItemRequest(ComposingAccount.Id, CurrentMailDraftItem.Id, string.Empty)); + downloadIfNeeded = false; + + var package = new DownloadMissingMessageRequested(CurrentMailDraftItem.AssignedAccount.Id, CurrentMailDraftItem.MailCopy); + var downloadResponse = await _winoServerConnectionManager.GetResponseAsync(package); + + if (downloadResponse.IsSuccess) + { + goto retry; + } } - //else - // DialogService.ShowMIMENotFoundMessage(); + else + DialogService.InfoBarMessage(Translator.Info_ComposerMissingMIMETitle, Translator.Info_ComposerMissingMIMEMessage, InfoBarMessageType.Error); return; } catch (IOException) { - DialogService.InfoBarMessage("Busy", "Mail is being processed. Please wait a moment and try again.", InfoBarMessageType.Warning); + DialogService.InfoBarMessage(Translator.Busy, Translator.Exception_MailProcessing, InfoBarMessageType.Warning); } catch (ComposerMimeNotFoundException) {