Handling of missing mime downloads and mail processed messages.

This commit is contained in:
Burak Kaan Köse
2024-08-17 20:19:01 +02:00
parent 747efac2ec
commit 55fe791c2a
3 changed files with 31 additions and 26 deletions

View File

@@ -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.", "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", "DiscordChannelDisclaimerTitle": "Important Discord Information",
"Draft": "Draft", "Draft": "Draft",
"Busy": "Busy",
"EditorToolbarOption_Draw": "Draw", "EditorToolbarOption_Draw": "Draw",
"EditorToolbarOption_Format": "Format", "EditorToolbarOption_Format": "Format",
"EditorToolbarOption_Insert": "Insert", "EditorToolbarOption_Insert": "Insert",
@@ -123,6 +124,7 @@
"ElementTheme_Light": "Light mode", "ElementTheme_Light": "Light mode",
"Emoji": "Emoji", "Emoji": "Emoji",
"Exception_WinoServerException": "Wino server failed.", "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_ImapAutoDiscoveryFailed": "Couldn't find mailbox settings.",
"Exception_ImapClientPoolFailed": "IMAP Client Pool failed.", "Exception_ImapClientPoolFailed": "IMAP Client Pool failed.",
"Exception_AuthenticationCanceled": "Authentication canceled", "Exception_AuthenticationCanceled": "Authentication canceled",

View File

@@ -583,6 +583,11 @@ namespace Wino.Core.Domain
/// </summary> /// </summary>
public static string Draft => Resources.GetTranslatedString(@"Draft"); public static string Draft => Resources.GetTranslatedString(@"Draft");
/// <summary>
/// Busy
/// </summary>
public static string Busy => Resources.GetTranslatedString(@"Busy");
/// <summary> /// <summary>
/// Draw /// Draw
/// </summary> /// </summary>
@@ -638,6 +643,11 @@ namespace Wino.Core.Domain
/// </summary> /// </summary>
public static string Exception_WinoServerException => Resources.GetTranslatedString(@"Exception_WinoServerException"); public static string Exception_WinoServerException => Resources.GetTranslatedString(@"Exception_WinoServerException");
/// <summary>
/// This mail is still being processed. Please try again after few seconds.
/// </summary>
public static string Exception_MailProcessing => Resources.GetTranslatedString(@"Exception_MailProcessing");
/// <summary> /// <summary>
/// Couldn't find mailbox settings. /// Couldn't find mailbox settings.
/// </summary> /// </summary>

View File

@@ -8,7 +8,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using MimeKit; using MimeKit;
using MimeKit.Utils;
using Wino.Core.Domain; using Wino.Core.Domain;
using Wino.Core.Domain.Entities; using Wino.Core.Domain.Entities;
using Wino.Core.Domain.Enums; using Wino.Core.Domain.Enums;
@@ -21,6 +20,7 @@ using Wino.Core.Extensions;
using Wino.Core.Services; using Wino.Core.Services;
using Wino.Mail.ViewModels.Data; using Wino.Mail.ViewModels.Data;
using Wino.Messaging.Client.Mails; using Wino.Messaging.Client.Mails;
using Wino.Messaging.Server;
namespace Wino.Mail.ViewModels namespace Wino.Mail.ViewModels
{ {
@@ -112,6 +112,7 @@ namespace Wino.Mail.ViewModels
private readonly IWinoRequestDelegator _worker; private readonly IWinoRequestDelegator _worker;
public readonly IFontService FontService; public readonly IFontService FontService;
public readonly IPreferencesService PreferencesService; public readonly IPreferencesService PreferencesService;
private readonly IWinoServerConnectionManager _winoServerConnectionManager;
public readonly IContactService ContactService; public readonly IContactService ContactService;
public ComposePageViewModel(IDialogService dialogService, public ComposePageViewModel(IDialogService dialogService,
@@ -124,7 +125,8 @@ namespace Wino.Mail.ViewModels
IWinoRequestDelegator worker, IWinoRequestDelegator worker,
IContactService contactService, IContactService contactService,
IFontService fontService, IFontService fontService,
IPreferencesService preferencesService) : base(dialogService) IPreferencesService preferencesService,
IWinoServerConnectionManager winoServerConnectionManager) : base(dialogService)
{ {
NativeAppService = nativeAppService; NativeAppService = nativeAppService;
_folderService = folderService; _folderService = folderService;
@@ -139,6 +141,7 @@ namespace Wino.Mail.ViewModels
SelectedToolbarSection = ToolbarSections[0]; SelectedToolbarSection = ToolbarSections[0];
PreferencesService = preferencesService; PreferencesService = preferencesService;
_winoServerConnectionManager = winoServerConnectionManager;
} }
[RelayCommand] [RelayCommand]
@@ -297,24 +300,6 @@ namespace Wino.Mail.ViewModels
ToItems.CollectionChanged -= ContactListCollectionChanged; ToItems.CollectionChanged -= ContactListCollectionChanged;
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) private void ContactListCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
@@ -375,6 +360,8 @@ namespace Wino.Mail.ViewModels
return; return;
} }
retry:
// Replying existing message. // Replying existing message.
MimeMessageInformation mimeMessageInformation = null; MimeMessageInformation mimeMessageInformation = null;
@@ -386,18 +373,24 @@ namespace Wino.Mail.ViewModels
{ {
if (downloadIfNeeded) if (downloadIfNeeded)
{ {
// TODO: Folder id needs to be passed. downloadIfNeeded = false;
// TODO: Send mail retrieve request.
// _worker.Queue(new FetchSingleItemRequest(ComposingAccount.Id, CurrentMailDraftItem.Id, string.Empty)); var package = new DownloadMissingMessageRequested(CurrentMailDraftItem.AssignedAccount.Id, CurrentMailDraftItem.MailCopy);
var downloadResponse = await _winoServerConnectionManager.GetResponseAsync<bool, DownloadMissingMessageRequested>(package);
if (downloadResponse.IsSuccess)
{
goto retry;
}
} }
//else else
// DialogService.ShowMIMENotFoundMessage(); DialogService.InfoBarMessage(Translator.Info_ComposerMissingMIMETitle, Translator.Info_ComposerMissingMIMEMessage, InfoBarMessageType.Error);
return; return;
} }
catch (IOException) 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) catch (ComposerMimeNotFoundException)
{ {