@@ -14,7 +14,8 @@ using MimeKit;
|
||||
using Serilog;
|
||||
using Wino.Core;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
@@ -30,10 +31,11 @@ using IMailService = Wino.Core.Domain.Interfaces.IMailService;
|
||||
|
||||
namespace Wino.Mail.ViewModels
|
||||
{
|
||||
public partial class MailRenderingPageViewModel : BaseViewModel,
|
||||
public partial class MailRenderingPageViewModel : MailBaseViewModel,
|
||||
IRecipient<NewMailItemRenderingRequestedEvent>,
|
||||
ITransferProgress // For listening IMAP message download progress.
|
||||
{
|
||||
private readonly IMailDialogService _dialogService;
|
||||
private readonly IUnderlyingThemeService _underlyingThemeService;
|
||||
|
||||
private readonly IMimeFileService _mimeFileService;
|
||||
@@ -129,7 +131,7 @@ namespace Wino.Mail.ViewModels
|
||||
public IPreferencesService PreferencesService { get; }
|
||||
public IPrintService PrintService { get; }
|
||||
|
||||
public MailRenderingPageViewModel(IDialogService dialogService,
|
||||
public MailRenderingPageViewModel(IMailDialogService dialogService,
|
||||
INativeAppService nativeAppService,
|
||||
IUnderlyingThemeService underlyingThemeService,
|
||||
IMimeFileService mimeFileService,
|
||||
@@ -143,8 +145,9 @@ namespace Wino.Mail.ViewModels
|
||||
IPreferencesService preferencesService,
|
||||
IPrintService printService,
|
||||
IApplicationConfiguration applicationConfiguration,
|
||||
IWinoServerConnectionManager winoServerConnectionManager) : base(dialogService)
|
||||
IWinoServerConnectionManager winoServerConnectionManager)
|
||||
{
|
||||
_dialogService = dialogService;
|
||||
NativeAppService = nativeAppService;
|
||||
StatePersistenceService = statePersistenceService;
|
||||
_contactService = contactService;
|
||||
@@ -168,11 +171,11 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
await _clipboardService.CopyClipboardAsync(copyText);
|
||||
|
||||
DialogService.InfoBarMessage(Translator.ClipboardTextCopied_Title, string.Format(Translator.ClipboardTextCopied_Message, copyText), InfoBarMessageType.Information);
|
||||
_dialogService.InfoBarMessage(Translator.ClipboardTextCopied_Title, string.Format(Translator.ClipboardTextCopied_Message, copyText), InfoBarMessageType.Information);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.GeneralTitle_Error, string.Format(Translator.ClipboardTextCopyFailed_Message, copyText), InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.GeneralTitle_Error, string.Format(Translator.ClipboardTextCopyFailed_Message, copyText), InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +199,7 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
if (!Uri.IsWellFormedUriString(CurrentRenderModel.UnsubscribeInfo.HttpLink, UriKind.RelativeOrAbsolute))
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_UnsubscribeLinkInvalidTitle, Translator.Info_UnsubscribeLinkInvalidMessage, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_UnsubscribeLinkInvalidTitle, Translator.Info_UnsubscribeLinkInvalidMessage, InfoBarMessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,23 +207,23 @@ namespace Wino.Mail.ViewModels
|
||||
// https://datatracker.ietf.org/doc/html/rfc8058
|
||||
if (CurrentRenderModel.UnsubscribeInfo.IsOneClick)
|
||||
{
|
||||
confirmed = await DialogService.ShowConfirmationDialogAsync(string.Format(Translator.DialogMessage_UnsubscribeConfirmationOneClickMessage, FromName), Translator.DialogMessage_UnsubscribeConfirmationTitle, Translator.Unsubscribe);
|
||||
confirmed = await _dialogService.ShowConfirmationDialogAsync(string.Format(Translator.DialogMessage_UnsubscribeConfirmationOneClickMessage, FromName), Translator.DialogMessage_UnsubscribeConfirmationTitle, Translator.Unsubscribe);
|
||||
if (!confirmed) return;
|
||||
|
||||
bool isOneClickUnsubscribed = await _unsubscriptionService.OneClickUnsubscribeAsync(CurrentRenderModel.UnsubscribeInfo);
|
||||
|
||||
if (isOneClickUnsubscribed)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Unsubscribe, string.Format(Translator.Info_UnsubscribeSuccessMessage, FromName), InfoBarMessageType.Success);
|
||||
_dialogService.InfoBarMessage(Translator.Unsubscribe, string.Format(Translator.Info_UnsubscribeSuccessMessage, FromName), InfoBarMessageType.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.GeneralTitle_Error, Translator.Info_UnsubscribeErrorMessage, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.GeneralTitle_Error, Translator.Info_UnsubscribeErrorMessage, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmed = await DialogService.ShowConfirmationDialogAsync(string.Format(Translator.DialogMessage_UnsubscribeConfirmationGoToWebsiteMessage, FromName), Translator.DialogMessage_UnsubscribeConfirmationTitle, Translator.DialogMessage_UnsubscribeConfirmationGoToWebsiteConfirmButton);
|
||||
confirmed = await _dialogService.ShowConfirmationDialogAsync(string.Format(Translator.DialogMessage_UnsubscribeConfirmationGoToWebsiteMessage, FromName), Translator.DialogMessage_UnsubscribeConfirmationTitle, Translator.DialogMessage_UnsubscribeConfirmationGoToWebsiteConfirmButton);
|
||||
if (!confirmed) return;
|
||||
|
||||
await NativeAppService.LaunchUriAsync(new Uri(CurrentRenderModel.UnsubscribeInfo.HttpLink));
|
||||
@@ -228,7 +231,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
else if (CurrentRenderModel.UnsubscribeInfo.MailToLink is not null)
|
||||
{
|
||||
confirmed = await DialogService.ShowConfirmationDialogAsync(string.Format(Translator.DialogMessage_UnsubscribeConfirmationMailtoMessage, FromName, new string(CurrentRenderModel.UnsubscribeInfo.MailToLink.Skip(7).ToArray())), Translator.DialogMessage_UnsubscribeConfirmationTitle, Translator.Unsubscribe);
|
||||
confirmed = await _dialogService.ShowConfirmationDialogAsync(string.Format(Translator.DialogMessage_UnsubscribeConfirmationMailtoMessage, FromName, new string(CurrentRenderModel.UnsubscribeInfo.MailToLink.Skip(7).ToArray())), Translator.DialogMessage_UnsubscribeConfirmationTitle, Translator.Unsubscribe);
|
||||
|
||||
if (!confirmed) return;
|
||||
|
||||
@@ -337,7 +340,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_MailRenderingFailedTitle, string.Format(Translator.Info_MailRenderingFailedMessage, ex.Message), InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_MailRenderingFailedTitle, string.Format(Translator.Info_MailRenderingFailedMessage, ex.Message), InfoBarMessageType.Error);
|
||||
|
||||
Crashes.TrackError(ex);
|
||||
Log.Error(ex, "Render Failed");
|
||||
@@ -360,7 +363,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.GeneralTitle_Error, ex.Message, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.GeneralTitle_Error, ex.Message, InfoBarMessageType.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -385,7 +388,7 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
if (mimeMessageInformation == null)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_MessageCorruptedTitle, Translator.Info_MessageCorruptedMessage, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_MessageCorruptedTitle, Translator.Info_MessageCorruptedMessage, InfoBarMessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -608,7 +611,7 @@ namespace Wino.Mail.ViewModels
|
||||
Log.Error(ex, WinoErrors.OpenAttachment);
|
||||
Crashes.TrackError(ex);
|
||||
|
||||
DialogService.InfoBarMessage(Translator.Info_AttachmentOpenFailedTitle, Translator.Info_AttachmentOpenFailedMessage, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_AttachmentOpenFailedTitle, Translator.Info_AttachmentOpenFailedMessage, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,20 +625,20 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
attachmentViewModel.IsBusy = true;
|
||||
|
||||
var pickedPath = await DialogService.PickWindowsFolderAsync();
|
||||
var pickedPath = await _dialogService.PickWindowsFolderAsync();
|
||||
|
||||
if (string.IsNullOrEmpty(pickedPath)) return;
|
||||
|
||||
await SaveAttachmentInternalAsync(attachmentViewModel, pickedPath);
|
||||
|
||||
DialogService.InfoBarMessage(Translator.Info_AttachmentSaveSuccessTitle, Translator.Info_AttachmentSaveSuccessMessage, InfoBarMessageType.Success);
|
||||
_dialogService.InfoBarMessage(Translator.Info_AttachmentSaveSuccessTitle, Translator.Info_AttachmentSaveSuccessMessage, InfoBarMessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, WinoErrors.SaveAttachment);
|
||||
Crashes.TrackError(ex);
|
||||
|
||||
DialogService.InfoBarMessage(Translator.Info_AttachmentSaveFailedTitle, Translator.Info_AttachmentSaveFailedMessage, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_AttachmentSaveFailedTitle, Translator.Info_AttachmentSaveFailedMessage, InfoBarMessageType.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -646,7 +649,7 @@ namespace Wino.Mail.ViewModels
|
||||
[RelayCommand]
|
||||
private async Task SaveAllAttachmentsAsync()
|
||||
{
|
||||
var pickedPath = await DialogService.PickWindowsFolderAsync();
|
||||
var pickedPath = await _dialogService.PickWindowsFolderAsync();
|
||||
|
||||
if (string.IsNullOrEmpty(pickedPath)) return;
|
||||
|
||||
@@ -658,14 +661,14 @@ namespace Wino.Mail.ViewModels
|
||||
await SaveAttachmentInternalAsync(attachmentViewModel, pickedPath);
|
||||
}
|
||||
|
||||
DialogService.InfoBarMessage(Translator.Info_AttachmentSaveSuccessTitle, Translator.Info_AttachmentSaveSuccessMessage, InfoBarMessageType.Success);
|
||||
_dialogService.InfoBarMessage(Translator.Info_AttachmentSaveSuccessTitle, Translator.Info_AttachmentSaveSuccessMessage, InfoBarMessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, WinoErrors.SaveAttachment);
|
||||
Crashes.TrackError(ex);
|
||||
|
||||
DialogService.InfoBarMessage(Translator.Info_AttachmentSaveFailedTitle, Translator.Info_AttachmentSaveFailedMessage, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_AttachmentSaveFailedTitle, Translator.Info_AttachmentSaveFailedMessage, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,17 +691,17 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
if (result == PrintingResult.Submitted)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.DialogMessage_PrintingSuccessTitle, Translator.DialogMessage_PrintingSuccessMessage, InfoBarMessageType.Success);
|
||||
_dialogService.InfoBarMessage(Translator.DialogMessage_PrintingSuccessTitle, Translator.DialogMessage_PrintingSuccessMessage, InfoBarMessageType.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
var message = string.Format(Translator.DialogMessage_PrintingFailedMessage, result);
|
||||
DialogService.InfoBarMessage(Translator.DialogMessage_PrintingFailedTitle, message, InfoBarMessageType.Warning);
|
||||
_dialogService.InfoBarMessage(Translator.DialogMessage_PrintingFailedTitle, message, InfoBarMessageType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(string.Empty, ex.Message, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(string.Empty, ex.Message, InfoBarMessageType.Error);
|
||||
Crashes.TrackError(ex);
|
||||
}
|
||||
}
|
||||
@@ -707,7 +710,7 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
var pickedFolder = await DialogService.PickWindowsFolderAsync();
|
||||
var pickedFolder = await _dialogService.PickWindowsFolderAsync();
|
||||
|
||||
if (string.IsNullOrEmpty(pickedFolder)) return;
|
||||
|
||||
@@ -717,14 +720,14 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
if (isSaved)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_PDFSaveSuccessTitle,
|
||||
_dialogService.InfoBarMessage(Translator.Info_PDFSaveSuccessTitle,
|
||||
string.Format(Translator.Info_PDFSaveSuccessMessage, pdfFilePath),
|
||||
InfoBarMessageType.Success);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_PDFSaveFailedTitle, ex.Message, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_PDFSaveFailedTitle, ex.Message, InfoBarMessageType.Error);
|
||||
Crashes.TrackError(ex);
|
||||
}
|
||||
}
|
||||
@@ -751,7 +754,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_FileLaunchFailedTitle, ex.Message, InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_FileLaunchFailedTitle, ex.Message, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -773,7 +776,7 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.Info_MailRenderingFailedTitle, string.Format(Translator.Info_MailRenderingFailedMessage, ex.Message), InfoBarMessageType.Error);
|
||||
_dialogService.InfoBarMessage(Translator.Info_MailRenderingFailedTitle, string.Format(Translator.Info_MailRenderingFailedMessage, ex.Message), InfoBarMessageType.Error);
|
||||
|
||||
Crashes.TrackError(ex);
|
||||
Log.Error(ex, "Render Failed");
|
||||
|
||||
Reference in New Issue
Block a user