9 Commits

Author SHA1 Message Date
Burak Kaan Köse ef12e0ff3a Init translations before showing nwe version notification. 2026-04-25 22:48:31 +02:00
Burak Kaan Köse e7e201758e Handle expired subscriptions. 2026-04-25 22:48:15 +02:00
Burak Kaan Köse 55ae6e1f3a Initial v2 launch notification. 2026-04-25 16:12:49 +02:00
Burak Kaan Köse 3ea8b8ac46 Bulk updates for gmail. 2026-04-25 16:00:49 +02:00
Burak Kaan Köse 8fe40e9fe3 Potential gmail history id fix. 2026-04-23 15:00:55 +02:00
Burak Kaan Köse 6f82cd4f26 Save as eml, translation updates 2026-04-23 13:23:05 +02:00
Burak Kaan Köse 81e28129b7 Set default language based on Windows language. 2026-04-22 22:39:19 +02:00
Burak Kaan Köse 39cde10fab Fix signature settings persistence and editing 2026-04-22 13:25:07 +02:00
Burak Kaan Köse ed54eb0284 Beta 2.0.6.0 2026-04-22 13:11:33 +02:00
58 changed files with 2759 additions and 226 deletions
+2 -1
View File
@@ -16,5 +16,6 @@ public enum AppLanguage
Greek, Greek,
PortugeseBrazil, PortugeseBrazil,
Italian, Italian,
Romanian Romanian,
Korean
} }
@@ -2,6 +2,8 @@
public interface IConfigurationService public interface IConfigurationService
{ {
bool Contains(string key);
void Set(string key, object value); void Set(string key, object value);
T Get<T>(string key, T defaultValue = default); T Get<T>(string key, T defaultValue = default);
@@ -34,6 +34,7 @@ public interface IMailService
/// <param name="accountId">Account to remove from</param> /// <param name="accountId">Account to remove from</param>
/// <param name="mailCopyId">Mail copy id to remove.</param> /// <param name="mailCopyId">Mail copy id to remove.</param>
Task DeleteMailAsync(Guid accountId, string mailCopyId); Task DeleteMailAsync(Guid accountId, string mailCopyId);
Task DeleteMailsAsync(Guid accountId, IEnumerable<string> mailCopyIds);
Task ChangeReadStatusAsync(string mailCopyId, bool isRead); Task ChangeReadStatusAsync(string mailCopyId, bool isRead);
Task ChangeFlagStatusAsync(string mailCopyId, bool isFlagged); Task ChangeFlagStatusAsync(string mailCopyId, bool isFlagged);
@@ -42,8 +43,11 @@ public interface IMailService
Task CreateAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId); Task CreateAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId);
Task DeleteAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId); Task DeleteAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId);
Task CreateAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments);
Task DeleteAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments);
Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package); Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package);
Task CreateMailsAsync(Guid accountId, IReadOnlyList<NewMailItemPackage> packages);
/// <summary> /// <summary>
/// Maps new mail item with the existing local draft copy. /// Maps new mail item with the existing local draft copy.
@@ -51,6 +51,11 @@ public interface INotificationBuilder
/// </summary> /// </summary>
void CreateStoreUpdateNotification(); void CreateStoreUpdateNotification();
/// <summary>
/// Shows the one-time release migration notification.
/// </summary>
void CreateReleaseMigrationNotification();
/// <summary> /// <summary>
/// Creates a calendar reminder toast for the specified calendar item. /// Creates a calendar reminder toast for the specified calendar item.
/// </summary> /// </summary>
@@ -127,6 +127,11 @@ public interface IPreferencesService : INotifyPropertyChanged
/// </summary> /// </summary>
bool IsHardDeleteProtectionEnabled { get; set; } bool IsHardDeleteProtectionEnabled { get; set; }
/// <summary>
/// Setting: Show the empty-folder command for junk/spam folders.
/// </summary>
bool IsShowEmptyJunkFolderEnabled { get; set; }
/// <summary> /// <summary>
/// Setting: Thread mails into conversations. /// Setting: Thread mails into conversations.
/// </summary> /// </summary>
@@ -0,0 +1,3 @@
namespace Wino.Core.Domain.Models.MailItem;
public sealed record MailFolderAssignmentUpdate(string MailCopyId, string RemoteFolderId);
@@ -45,6 +45,7 @@ public class WinoTranslationDictionary : Dictionary<string, string>
AppLanguage.Greek => "el_GR", AppLanguage.Greek => "el_GR",
AppLanguage.PortugeseBrazil => "pt_BR", AppLanguage.PortugeseBrazil => "pt_BR",
AppLanguage.Romanian => "ro_RO", AppLanguage.Romanian => "ro_RO",
AppLanguage.Korean => "ko_KR",
_ => "en_US", _ => "en_US",
}; };
} }
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Изтриване на този акаунт", "SettingsDeleteAccount_Title": "Изтриване на този акаунт",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Защита от окончателно изтриване", "SettingsDeleteProtection_Title": "Защита от окончателно изтриване",
"SettingsEmptyJunkFolderCommand_Description": "Покажи командата за изпразване на папка в папките Спам. Това действие няма да изисква потвърждение и ще изтрие всички имейли в папката за спам веднага.",
"SettingsEmptyJunkFolderCommand_Title": "Покажи командата за изпразване на папка Спам",
"SettingsDiagnostics_Description": "За разработчици", "SettingsDiagnostics_Description": "За разработчици",
"SettingsDiagnostics_DiagnosticId_Description": "Споделете този идентификационен номер с разработчиците, когато ви помолят, за да получите помощ за проблемите, с които се сблъсквате в Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Споделете този идентификационен номер с разработчиците, когато ви помолят, за да получите помощ за проблемите, с които се сблъсквате в Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Идентификатор за диагностика", "SettingsDiagnostics_DiagnosticId_Title": "Идентификатор за диагностика",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "Mostra la comanda per buidar la carpeta de correu brossa. Aquesta acció no demanarà confirmació i eliminarà immediatament tots els correus de la carpeta de correu brossa.",
"SettingsEmptyJunkFolderCommand_Title": "Mostra la comanda per buidar la carpeta de correu brossa",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Smazat tento účet", "SettingsDeleteAccount_Title": "Smazat tento účet",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Ochrana proti trvalému smazání", "SettingsDeleteProtection_Title": "Ochrana proti trvalému smazání",
"SettingsEmptyJunkFolderCommand_Description": "Zobrazit příkaz pro vyprázdnění složky ve složkách Nevyžádaná pošta (spam). Tato akce nepožádá o potvrzení a ihned smaže všechny e-maily ve složce spamu.",
"SettingsEmptyJunkFolderCommand_Title": "Zobrazit příkaz pro vyprázdnění složky spamu",
"SettingsDiagnostics_Description": "Pro vývojáře", "SettingsDiagnostics_Description": "Pro vývojáře",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "Vis kommandoen til at tøm mappen i Junk/Spam-mapperne. Denne handling vil ikke bede om bekræftelse og vil straks slette alle mails i spam-mappen.",
"SettingsEmptyJunkFolderCommand_Title": "Vis kommandoen til at tømme spam-mappen",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Dieses Konto löschen", "SettingsDeleteAccount_Title": "Dieses Konto löschen",
"SettingsDeleteProtection_Description": "Sollte Wino jedes Mal nachfragen, wenn Sie eine Mail mit Umschalten + Entfernen permanent löschen möchten?", "SettingsDeleteProtection_Description": "Sollte Wino jedes Mal nachfragen, wenn Sie eine Mail mit Umschalten + Entfernen permanent löschen möchten?",
"SettingsDeleteProtection_Title": "Schutz vor permanenter Löschung", "SettingsDeleteProtection_Title": "Schutz vor permanenter Löschung",
"SettingsEmptyJunkFolderCommand_Description": "Zeige den Befehl zum Leeren des Junk-/Spam-Ordners an. Diese Aktion wird keine Bestätigung erfordern und löscht sofort alle E-Mails im Spam-Ordner.",
"SettingsEmptyJunkFolderCommand_Title": "Befehl zum Leeren des Spam-Ordners anzeigen",
"SettingsDiagnostics_Description": "Für Entwickler", "SettingsDiagnostics_Description": "Für Entwickler",
"SettingsDiagnostics_DiagnosticId_Description": "Teilen Sie diese ID mit den Entwicklern, wenn Sie um Hilfe bei Problemen in Wino Mail gebeten werden.", "SettingsDiagnostics_DiagnosticId_Description": "Teilen Sie diese ID mit den Entwicklern, wenn Sie um Hilfe bei Problemen in Wino Mail gebeten werden.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnose-ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnose-ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Διαγραφή αυτού του λογαριασμού", "SettingsDeleteAccount_Title": "Διαγραφή αυτού του λογαριασμού",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Προστασία Μόνιμης Διαγραφής", "SettingsDeleteProtection_Title": "Προστασία Μόνιμης Διαγραφής",
"SettingsEmptyJunkFolderCommand_Description": "Εμφάνιση της εντολής εκκένωσης φακέλου στους φακέλους Junk/Spam. Αυτή η ενέργεια δεν θα ζητήσει επιβεβαίωση και θα διαγράψει αμέσως όλα τα ηλεκτρονικά μηνύματα στον φάκελο Spam.",
"SettingsEmptyJunkFolderCommand_Title": "Εμφάνιση εντολής εκκένωσης φακέλου Spam",
"SettingsDiagnostics_Description": "Για προγραμματιστές", "SettingsDiagnostics_Description": "Για προγραμματιστές",
"SettingsDiagnostics_DiagnosticId_Description": "Μοιραστείτε αυτό το ID με τους προγραμματιστές όταν σας ζητηθεί να λάβετε βοήθεια για τα θέματα που αντιμετωπίζετε στο Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Μοιραστείτε αυτό το ID με τους προγραμματιστές όταν σας ζητηθεί να λάβετε βοήθεια για τα θέματα που αντιμετωπίζετε στο Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Διαγνωστικό ID", "SettingsDiagnostics_DiagnosticId_Title": "Διαγνωστικό ID",
@@ -92,11 +92,13 @@
"Buttons_Discard": "Discard", "Buttons_Discard": "Discard",
"Buttons_Dismiss": "Dismiss", "Buttons_Dismiss": "Dismiss",
"Buttons_Edit": "Edit", "Buttons_Edit": "Edit",
"Buttons_EML": "EML",
"Buttons_EnableImageRendering": "Enable", "Buttons_EnableImageRendering": "Enable",
"Buttons_Multiselect": "Select Multiple", "Buttons_Multiselect": "Select Multiple",
"Buttons_Manage": "Manage", "Buttons_Manage": "Manage",
"Buttons_No": "No", "Buttons_No": "No",
"Buttons_Open": "Open", "Buttons_Open": "Open",
"Buttons_PDF": "PDF",
"Buttons_Purchase": "Purchase", "Buttons_Purchase": "Purchase",
"Buttons_RateWino": "Rate Wino", "Buttons_RateWino": "Rate Wino",
"Buttons_Reset": "Reset", "Buttons_Reset": "Reset",
@@ -595,6 +597,9 @@
"Info_MessageCorruptedTitle": "Error", "Info_MessageCorruptedTitle": "Error",
"Info_MissingFolderMessage": "{0} doesn't exist for this account.", "Info_MissingFolderMessage": "{0} doesn't exist for this account.",
"Info_MissingFolderTitle": "Missing Folder", "Info_MissingFolderTitle": "Missing Folder",
"Info_EMLSaveFailedTitle": "Failed to save EML file",
"Info_EMLSaveSuccessMessage": "EML file is saved to {0}",
"Info_EMLSaveSuccessTitle": "Success",
"Info_PDFSaveFailedTitle": "Failed to save PDF file", "Info_PDFSaveFailedTitle": "Failed to save PDF file",
"Info_PDFSaveSuccessMessage": "PDF file is saved to {0}", "Info_PDFSaveSuccessMessage": "PDF file is saved to {0}",
"Info_PDFSaveSuccessTitle": "Success", "Info_PDFSaveSuccessTitle": "Success",
@@ -699,6 +704,8 @@
"Notifications_WinoUpdatedTitle": "Wino Mail has been updated.", "Notifications_WinoUpdatedTitle": "Wino Mail has been updated.",
"Notifications_StoreUpdateAvailableTitle": "Update available", "Notifications_StoreUpdateAvailableTitle": "Update available",
"Notifications_StoreUpdateAvailableMessage": "A newer version of Wino Mail is ready to install from Microsoft Store.", "Notifications_StoreUpdateAvailableMessage": "A newer version of Wino Mail is ready to install from Microsoft Store.",
"Notifications_ReleaseMigrationTitle": "New Wino Mail & Calendar",
"Notifications_ReleaseMigrationMessage": "Wino Mail got updated to the next version. Please re-create your accounts and start using the next version including calendar, mail templates, shortcuts, and a bunch of other improvements.",
"OnlineSearchFailed_Message": "Failed to perform search\n{0}\n\nListing offline mails.", "OnlineSearchFailed_Message": "Failed to perform search\n{0}\n\nListing offline mails.",
"OnlineSearchTry_Line1": "Can't find what you are looking for?", "OnlineSearchTry_Line1": "Can't find what you are looking for?",
"OnlineSearchTry_Line2": "Try online search.", "OnlineSearchTry_Line2": "Try online search.",
@@ -836,6 +843,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "Show the empty-folder command in Junk/Spam folders. This action will not ask for confirmation and will delete all mails in the spam folder immediately.",
"SettingsEmptyJunkFolderCommand_Title": "Show empty spam folder command",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Eliminar esta cuenta", "SettingsDeleteAccount_Title": "Eliminar esta cuenta",
"SettingsDeleteProtection_Description": "¿Debería Wino pedirte confirmación cada vez que intentas eliminar un correo usando las teclas Shift + Supr?", "SettingsDeleteProtection_Description": "¿Debería Wino pedirte confirmación cada vez que intentas eliminar un correo usando las teclas Shift + Supr?",
"SettingsDeleteProtection_Title": "Protección de Eliminación Permanente", "SettingsDeleteProtection_Title": "Protección de Eliminación Permanente",
"SettingsEmptyJunkFolderCommand_Description": "Mostrar el comando para vaciar la carpeta en las carpetas de correo no deseado. Esta acción no solicitará confirmación y eliminará todos los correos de la carpeta de correo no deseado de inmediato.",
"SettingsEmptyJunkFolderCommand_Title": "Mostrar el comando para vaciar la carpeta de correo no deseado",
"SettingsDiagnostics_Description": "Para desarrolladores", "SettingsDiagnostics_Description": "Para desarrolladores",
"SettingsDiagnostics_DiagnosticId_Description": "Comparte este ID con los desarrolladores cuando se les pida ayuda para los problemas que experimentas en Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Comparte este ID con los desarrolladores cuando se les pida ayuda para los problemas que experimentas en Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "ID de Diagnóstico", "SettingsDiagnostics_DiagnosticId_Title": "ID de Diagnóstico",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "Näytä roskapostikansioiden tyhjennyskomento. Tämä toimenpide ei kysy vahvistusta ja poistaa välittömästi kaikki sähköpostit roskapostikansioista.",
"SettingsEmptyJunkFolderCommand_Title": "Näytä roskapostikansioiden tyhjennyskomento",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Supprimer ce compte", "SettingsDeleteAccount_Title": "Supprimer ce compte",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Protection contre la suppression permanente", "SettingsDeleteProtection_Title": "Protection contre la suppression permanente",
"SettingsEmptyJunkFolderCommand_Description": "Afficher la commande de vidage du dossier dans les dossiers de courrier indésirable. Cette action ne demandera pas de confirmation et supprimera immédiatement tous les courriels du dossier de courrier indésirable.",
"SettingsEmptyJunkFolderCommand_Title": "Afficher la commande pour vider le dossier de courrier indésirable",
"SettingsDiagnostics_Description": "Pour les développeurs", "SettingsDiagnostics_Description": "Pour les développeurs",
"SettingsDiagnostics_DiagnosticId_Description": "Partagez cet identifiant avec les développeurs lorsqu'ils vous aideront à résoudre les problèmes que vous rencontrez dans Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Partagez cet identifiant avec les développeurs lorsqu'ils vous aideront à résoudre les problèmes que vous rencontrez dans Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "ID de diagnostic", "SettingsDiagnostics_DiagnosticId_Title": "ID de diagnostic",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "Mostrar o comando para baleirar a carpeta de correo lixo. Esta acción non pedirá confirmación e eliminará de inmediato todos os correos da carpeta de correo lixo.",
"SettingsEmptyJunkFolderCommand_Title": "Mostrar o comando para baleirar a carpeta de correo lixo",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Hapus akun ini", "SettingsDeleteAccount_Title": "Hapus akun ini",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Perlindungan Hapus Permanen", "SettingsDeleteProtection_Title": "Perlindungan Hapus Permanen",
"SettingsEmptyJunkFolderCommand_Description": "Tampilkan perintah kosongkan folder pada folder Junk/Spam. Tindakan ini tidak akan meminta konfirmasi dan akan menghapus semua email di folder spam segera.",
"SettingsEmptyJunkFolderCommand_Title": "Perintah kosongkan folder Spam",
"SettingsDiagnostics_Description": "Untuk pengembang", "SettingsDiagnostics_Description": "Untuk pengembang",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Elimina questo account", "SettingsDeleteAccount_Title": "Elimina questo account",
"SettingsDeleteProtection_Description": "Dovrebbe Wino chiederti la conferma ogni volta che provi a eliminare definitivamente un messaggio utilizzando Maiusc + Canc?", "SettingsDeleteProtection_Description": "Dovrebbe Wino chiederti la conferma ogni volta che provi a eliminare definitivamente un messaggio utilizzando Maiusc + Canc?",
"SettingsDeleteProtection_Title": "Protezione eliminazione permanente", "SettingsDeleteProtection_Title": "Protezione eliminazione permanente",
"SettingsEmptyJunkFolderCommand_Description": "Mostra il comando per svuotare le cartelle Junk/Spam. Questa azione non richiederà alcuna conferma e eliminerà immediatamente tutte le email nelle cartelle Junk/Spam.",
"SettingsEmptyJunkFolderCommand_Title": "Mostra il comando per svuotare la cartella Junk/Spam",
"SettingsDiagnostics_Description": "Per gli sviluppatori", "SettingsDiagnostics_Description": "Per gli sviluppatori",
"SettingsDiagnostics_DiagnosticId_Description": "Condividi questo ID con gli sviluppatori quando richiesto per ricevere aiuto in merito ai problemi che hai con Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Condividi questo ID con gli sviluppatori quando richiesto per ricevere aiuto in merito ai problemi che hai con Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "ID diagnostica", "SettingsDiagnostics_DiagnosticId_Title": "ID diagnostica",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "迷惑メール フォルダーの「空にする」コマンドを表示します。この操作は確認を求めず、迷惑メール フォルダー内のすべてのメールを即座に削除します。",
"SettingsEmptyJunkFolderCommand_Title": "迷惑メール フォルダーを空にするコマンドを表示",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
File diff suppressed because it is too large Load Diff
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Delete this account", "SettingsDeleteAccount_Title": "Delete this account",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Permanent Delete Protection", "SettingsDeleteProtection_Title": "Permanent Delete Protection",
"SettingsEmptyJunkFolderCommand_Description": "Rodyti komandą Išvalyti šlamšto aplanką šlamšto aplankuose. Šis veiksmas nepaprašys patvirtinimo ir nedelsiant ištrins visus el. laiškus šlamšto aplanke.",
"SettingsEmptyJunkFolderCommand_Title": "Rodyti komandą Išvalyti šlamšto aplanką",
"SettingsDiagnostics_Description": "For developers", "SettingsDiagnostics_Description": "For developers",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Verwijder dit account", "SettingsDeleteAccount_Title": "Verwijder dit account",
"SettingsDeleteProtection_Description": "Moet Wino u om bevestiging vragen elke keer wanneer u een e-mail permanent verwijdert met de Shift + Del toetsen?", "SettingsDeleteProtection_Description": "Moet Wino u om bevestiging vragen elke keer wanneer u een e-mail permanent verwijdert met de Shift + Del toetsen?",
"SettingsDeleteProtection_Title": "Bescherming tegen permanent verwijderen", "SettingsDeleteProtection_Title": "Bescherming tegen permanent verwijderen",
"SettingsEmptyJunkFolderCommand_Description": "Toon het lege-map-commando in de Junk/Spam-mappen. Deze actie vraagt geen bevestiging en verwijdert onmiddellijk alle e-mails in de spam-map.",
"SettingsEmptyJunkFolderCommand_Title": "Toon leeg-map-commando",
"SettingsDiagnostics_Description": "Voor ontwikkelaars", "SettingsDiagnostics_Description": "Voor ontwikkelaars",
"SettingsDiagnostics_DiagnosticId_Description": "Deel dit ID met de ontwikkelaars wanneer er om hulp gevraagd wordt voor de problemen die u in Wino Mail ervaart.", "SettingsDiagnostics_DiagnosticId_Description": "Deel dit ID met de ontwikkelaars wanneer er om hulp gevraagd wordt voor de problemen die u in Wino Mail ervaart.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostische ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostische ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Usuń to konto", "SettingsDeleteAccount_Title": "Usuń to konto",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Ochrona przed trwałym usunięciem", "SettingsDeleteProtection_Title": "Ochrona przed trwałym usunięciem",
"SettingsEmptyJunkFolderCommand_Description": "Pokaż polecenie opróżniania pustego folderu w folderach Junk/Spam. Ta akcja nie poprosi o potwierdzenie i natychmiast usunie wszystkie wiadomości z folderu Spam.",
"SettingsEmptyJunkFolderCommand_Title": "Pokaż polecenie opróżniania pustego folderu Spam",
"SettingsDiagnostics_Description": "Dla programistów", "SettingsDiagnostics_Description": "Dla programistów",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Apagar esta conta", "SettingsDeleteAccount_Title": "Apagar esta conta",
"SettingsDeleteProtection_Description": "O Wino deve solicitar confirmação sempre que você tentar excluir permanentemente um e-mail usando as teclas Shift + Del?", "SettingsDeleteProtection_Description": "O Wino deve solicitar confirmação sempre que você tentar excluir permanentemente um e-mail usando as teclas Shift + Del?",
"SettingsDeleteProtection_Title": "Proteção de exclusão permanente", "SettingsDeleteProtection_Title": "Proteção de exclusão permanente",
"SettingsEmptyJunkFolderCommand_Description": "Mostrar o comando para esvaziar a pasta nas pastas de Lixo/Spam. Esta ação não solicitará confirmação e excluirá imediatamente todas as mensagens na pasta de spam.",
"SettingsEmptyJunkFolderCommand_Title": "Mostrar o comando para esvaziar a pasta de Spam",
"SettingsDiagnostics_Description": "Para desenvolvedores", "SettingsDiagnostics_Description": "Para desenvolvedores",
"SettingsDiagnostics_DiagnosticId_Description": "Compartilhe esta identificação com os desenvolvedores quando solicitado para obter ajuda para os problemas que você experimentar no Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Compartilhe esta identificação com os desenvolvedores quando solicitado para obter ajuda para os problemas que você experimentar no Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "ID de diagnóstico", "SettingsDiagnostics_DiagnosticId_Title": "ID de diagnóstico",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Ștergeți acest cont", "SettingsDeleteAccount_Title": "Ștergeți acest cont",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Protecție Ștergere Permanentă", "SettingsDeleteProtection_Title": "Protecție Ștergere Permanentă",
"SettingsEmptyJunkFolderCommand_Description": "Afișează comanda de golire a folderelor Junk/Spam. Această acțiune nu va solicita confirmare și va șterge imediat toate mesajele din folderul de spam.",
"SettingsEmptyJunkFolderCommand_Title": "Afișează comanda pentru golirea folderului de spam.",
"SettingsDiagnostics_Description": "Pentru dezvoltatori", "SettingsDiagnostics_Description": "Pentru dezvoltatori",
"SettingsDiagnostics_DiagnosticId_Description": "Partajați acest ID cu dezvoltatorii atunci când le cereți ajutor pentru problemele pe care le întâmpinați în Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Partajați acest ID cu dezvoltatorii atunci când le cereți ajutor pentru problemele pe care le întâmpinați în Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "ID de Diagnosticare", "SettingsDiagnostics_DiagnosticId_Title": "ID de Diagnosticare",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Удалить эту учетную запись", "SettingsDeleteAccount_Title": "Удалить эту учетную запись",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Защита от окончательного удаления", "SettingsDeleteProtection_Title": "Защита от окончательного удаления",
"SettingsEmptyJunkFolderCommand_Description": "Показать команду очистки пустой папки в папках Спам. Это действие не будет запрашивать подтверждение и сразу удалит все письма в папке спама.",
"SettingsEmptyJunkFolderCommand_Title": "Показать команду очистки пустой папки в папках Спам",
"SettingsDiagnostics_Description": "Для разработчиков", "SettingsDiagnostics_Description": "Для разработчиков",
"SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Share this ID with the developers when asked to get help for the issues you experience in Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostic ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Odstrániť tento účet", "SettingsDeleteAccount_Title": "Odstrániť tento účet",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Ochrana pred trvalým odstránením", "SettingsDeleteProtection_Title": "Ochrana pred trvalým odstránením",
"SettingsEmptyJunkFolderCommand_Description": "Zobraziť príkaz na vyprázdnenie priečinka v priečinkoch Nevyžiadaná pošta / Spam. Táto akcia nepožaduje potvrdenie a okamžite vymaže všetky e-maily zo spamového priečinka.",
"SettingsEmptyJunkFolderCommand_Title": "Zobraziť príkaz na vyprázdnenie spamového priečinka",
"SettingsDiagnostics_Description": "Pre vývojárov", "SettingsDiagnostics_Description": "Pre vývojárov",
"SettingsDiagnostics_DiagnosticId_Description": "Zdieľajte toto ID s vývojármi, keď budete požiadaní o pomoc pri problémoch, ktoré sa vám vyskytnú v aplikácii Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Zdieľajte toto ID s vývojármi, keď budete požiadaní o pomoc pri problémoch, ktoré sa vám vyskytnú v aplikácii Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "Diagnostické ID", "SettingsDiagnostics_DiagnosticId_Title": "Diagnostické ID",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Bu hesabı sil", "SettingsDeleteAccount_Title": "Bu hesabı sil",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Kalıcı Silme Koruması", "SettingsDeleteProtection_Title": "Kalıcı Silme Koruması",
"SettingsEmptyJunkFolderCommand_Description": "Gereksiz Posta/Spam klasörlerinde boş klasör komutunu göster. Bu işlem onay istemeyecek ve spam klasöründeki tüm mailleri hemen silecektir.",
"SettingsEmptyJunkFolderCommand_Title": "Boş Spam Klasörü Komutunu Göster",
"SettingsDiagnostics_Description": "Geliştiriciler için", "SettingsDiagnostics_Description": "Geliştiriciler için",
"SettingsDiagnostics_DiagnosticId_Description": "Bu ID'yi geliştiriciler ile paylaşarak Wino Mail ile yaşadığınız sorunlar hakkında çözümlere ulaşabilirsiniz.", "SettingsDiagnostics_DiagnosticId_Description": "Bu ID'yi geliştiriciler ile paylaşarak Wino Mail ile yaşadığınız sorunlar hakkında çözümlere ulaşabilirsiniz.",
"SettingsDiagnostics_DiagnosticId_Title": "Hata Ayıklama ID'si", "SettingsDiagnostics_DiagnosticId_Title": "Hata Ayıklama ID'si",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "Видалити цей обліковий запис", "SettingsDeleteAccount_Title": "Видалити цей обліковий запис",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "Захист від остаточного видалення", "SettingsDeleteProtection_Title": "Захист від остаточного видалення",
"SettingsEmptyJunkFolderCommand_Description": "Показати команду очищення порожньої папки у папках Небажана пошта/Спам. Ця дія не вимагатиме підтвердження і негайно видалить усі листи з папки зі спамом.",
"SettingsEmptyJunkFolderCommand_Title": "Показати команду очищення порожньої папки Спам",
"SettingsDiagnostics_Description": "Для розробників", "SettingsDiagnostics_Description": "Для розробників",
"SettingsDiagnostics_DiagnosticId_Description": "Поділіться цим ID з розробниками, коли попросять, щоб отримати допомогу щодо проблем, з якими Ви зіткнулися у Wino Mail.", "SettingsDiagnostics_DiagnosticId_Description": "Поділіться цим ID з розробниками, коли попросять, щоб отримати допомогу щодо проблем, з якими Ви зіткнулися у Wino Mail.",
"SettingsDiagnostics_DiagnosticId_Title": "ID діагностики", "SettingsDiagnostics_DiagnosticId_Title": "ID діагностики",
@@ -836,6 +836,8 @@
"SettingsDeleteAccount_Title": "删除此账户", "SettingsDeleteAccount_Title": "删除此账户",
"SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?", "SettingsDeleteProtection_Description": "Should Wino ask you for confirmation every time you try to permanently delete a mail using Shift + Del keys?",
"SettingsDeleteProtection_Title": "永久性删除保护", "SettingsDeleteProtection_Title": "永久性删除保护",
"SettingsEmptyJunkFolderCommand_Description": "在垃圾邮件/垃圾箱文件夹中显示清空文件夹命令。此操作不会要求确认,将立即删除垃圾邮件文件夹中的所有邮件。",
"SettingsEmptyJunkFolderCommand_Title": "显示清空垃圾邮件文件夹的命令",
"SettingsDiagnostics_Description": "开发者选项", "SettingsDiagnostics_Description": "开发者选项",
"SettingsDiagnostics_DiagnosticId_Description": "如需联系开发人员请求帮助,请提供此 ID。", "SettingsDiagnostics_DiagnosticId_Description": "如需联系开发人员请求帮助,请提供此 ID。",
"SettingsDiagnostics_DiagnosticId_Title": "诊断 ID", "SettingsDiagnostics_DiagnosticId_Title": "诊断 ID",
@@ -0,0 +1,24 @@
using FluentAssertions;
using Wino.Core.Domain.Enums;
using Wino.Services;
using Xunit;
namespace Wino.Core.Tests.Services;
public class TranslationServiceTests
{
[Theory]
[InlineData("pl-PL", AppLanguage.Polish)]
[InlineData("de-AT", AppLanguage.Deutsch)]
[InlineData("pt-PT", AppLanguage.PortugeseBrazil)]
[InlineData("zh-TW", AppLanguage.Chinese)]
[InlineData("tr_TR", AppLanguage.Turkish)]
[InlineData("ko-KR", AppLanguage.Korean)]
[InlineData("nl-NL", AppLanguage.English)]
public void ResolveSupportedLanguage_ReturnsExpectedLanguage(string languageTag, AppLanguage expectedLanguage)
{
var result = TranslationService.ResolveSupportedLanguage([languageTag]);
result.Should().Be(expectedLanguage);
}
}
@@ -19,6 +19,32 @@ namespace Wino.Core.Tests.Synchronizers;
public sealed class GmailSynchronizerRequestSuccessTests public sealed class GmailSynchronizerRequestSuccessTests
{ {
[Fact]
public async Task UpdateAccountSyncIdentifierAsync_EmptyStoredIdentifier_PersistsFirstHistoryCursor()
{
var changeProcessor = new Mock<IGmailChangeProcessor>(MockBehavior.Strict);
changeProcessor
.Setup(x => x.UpdateAccountDeltaSynchronizationIdentifierAsync(It.IsAny<Guid>(), "123"))
.ReturnsAsync("123");
var synchronizer = CreateSynchronizer(changeProcessor.Object, synchronizationDeltaIdentifier: string.Empty);
await InvokeUpdateAccountSyncIdentifierAsync(synchronizer, 123);
changeProcessor.Verify(x => x.UpdateAccountDeltaSynchronizationIdentifierAsync(It.IsAny<Guid>(), "123"), Times.Once);
}
[Fact]
public async Task UpdateAccountSyncIdentifierAsync_OlderHistoryCursor_DoesNotRegressStoredCursor()
{
var changeProcessor = new Mock<IGmailChangeProcessor>(MockBehavior.Strict);
var synchronizer = CreateSynchronizer(changeProcessor.Object, synchronizationDeltaIdentifier: "456");
await InvokeUpdateAccountSyncIdentifierAsync(synchronizer, 123);
changeProcessor.Verify(x => x.UpdateAccountDeltaSynchronizationIdentifierAsync(It.IsAny<Guid>(), It.IsAny<string>()), Times.Never);
}
[Fact] [Fact]
public async Task ProcessSingleNativeRequestResponseAsync_BatchMarkReadRequest_PersistsLocalReadStateForEachMail() public async Task ProcessSingleNativeRequestResponseAsync_BatchMarkReadRequest_PersistsLocalReadStateForEachMail()
{ {
@@ -209,13 +235,15 @@ public sealed class GmailSynchronizerRequestSuccessTests
private static GmailSynchronizer CreateSynchronizer( private static GmailSynchronizer CreateSynchronizer(
IGmailChangeProcessor changeProcessor, IGmailChangeProcessor changeProcessor,
IGmailSynchronizerErrorHandlerFactory? errorFactory = null) IGmailSynchronizerErrorHandlerFactory? errorFactory = null,
string? synchronizationDeltaIdentifier = null)
{ {
var account = new MailAccount var account = new MailAccount
{ {
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
Name = "Gmail", Name = "Gmail",
Address = "user@example.com" Address = "user@example.com",
SynchronizationDeltaIdentifier = synchronizationDeltaIdentifier
}; };
var authenticator = new Mock<IGmailAuthenticator>(MockBehavior.Loose); var authenticator = new Mock<IGmailAuthenticator>(MockBehavior.Loose);
@@ -249,4 +277,17 @@ public sealed class GmailSynchronizerRequestSuccessTests
task.Should().NotBeNull(); task.Should().NotBeNull();
await task!; await task!;
} }
private static async Task InvokeUpdateAccountSyncIdentifierAsync(GmailSynchronizer synchronizer, ulong historyId)
{
var method = typeof(GmailSynchronizer).GetMethod(
"UpdateAccountSyncIdentifierAsync",
BindingFlags.Instance | BindingFlags.NonPublic);
method.Should().NotBeNull();
var task = method!.Invoke(synchronizer, [historyId]) as Task;
task.Should().NotBeNull();
await task!;
}
} }
@@ -571,6 +571,19 @@ public partial class WinoAccountManagementPageViewModel : CoreBaseViewModel,
} }
var aiStatus = aiStatusResponse.Result; var aiStatus = aiStatusResponse.Result;
if (IsExpiredAiEntitlement(aiStatus.EntitlementStatus))
{
await ExecuteUIThread(() =>
{
_aiPackAddOn.IsPurchased = false;
_aiPackAddOn.HasUsageData = false;
_aiPackAddOn.ErrorText = string.Empty;
_aiPackAddOn.RenewalText = string.Empty;
_aiPackAddOn.UsageResetText = string.Empty;
});
return;
}
if (aiStatus.MonthlyLimit is not int usageLimit || usageLimit <= 0 || aiStatus.Used is not int usageCount) if (aiStatus.MonthlyLimit is not int usageLimit || usageLimit <= 0 || aiStatus.Used is not int usageCount)
{ {
await ExecuteUIThread(() => await ExecuteUIThread(() =>
@@ -613,4 +626,7 @@ public partial class WinoAccountManagementPageViewModel : CoreBaseViewModel,
}); });
} }
} }
private static bool IsExpiredAiEntitlement(string? entitlementStatus)
=> string.Equals(entitlementStatus, "Expired", StringComparison.OrdinalIgnoreCase);
} }
@@ -30,7 +30,9 @@ public interface IDefaultChangeProcessor
Task ChangeMailReadStatusAsync(string mailCopyId, bool isRead); Task ChangeMailReadStatusAsync(string mailCopyId, bool isRead);
Task ChangeFlagStatusAsync(string mailCopyId, bool isFlagged); Task ChangeFlagStatusAsync(string mailCopyId, bool isFlagged);
Task<bool> CreateMailAsync(Guid AccountId, NewMailItemPackage package); Task<bool> CreateMailAsync(Guid AccountId, NewMailItemPackage package);
Task CreateMailsAsync(Guid accountId, IReadOnlyList<NewMailItemPackage> packages);
Task DeleteMailAsync(Guid accountId, string mailId); Task DeleteMailAsync(Guid accountId, string mailId);
Task DeleteMailsAsync(Guid accountId, IEnumerable<string> mailIds);
Task<List<MailCopy>> GetDownloadedUnreadMailsAsync(Guid accountId, IEnumerable<string> downloadedMailCopyIds); Task<List<MailCopy>> GetDownloadedUnreadMailsAsync(Guid accountId, IEnumerable<string> downloadedMailCopyIds);
Task SaveMimeFileAsync(Guid fileId, MimeMessage mimeMessage, Guid accountId); Task SaveMimeFileAsync(Guid fileId, MimeMessage mimeMessage, Guid accountId);
Task DeleteFolderAsync(Guid accountId, string remoteFolderId); Task DeleteFolderAsync(Guid accountId, string remoteFolderId);
@@ -56,6 +58,9 @@ public interface IDefaultChangeProcessor
Task UpdateCalendarDeltaSynchronizationToken(Guid calendarId, string deltaToken); Task UpdateCalendarDeltaSynchronizationToken(Guid calendarId, string deltaToken);
Task<List<MailCopy>> GetMailCopiesAsync(IEnumerable<string> mailCopyIds); Task<List<MailCopy>> GetMailCopiesAsync(IEnumerable<string> mailCopyIds);
Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package); Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package);
Task ApplyMailStateUpdatesAsync(IEnumerable<MailCopyStateUpdate> updates);
Task CreateAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments);
Task DeleteAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments);
Task DeleteUserMailCacheAsync(Guid accountId); Task DeleteUserMailCacheAsync(Guid accountId);
Task UpsertMailInvitationCalendarMappingAsync(MailInvitationCalendarMapping mapping); Task UpsertMailInvitationCalendarMappingAsync(MailInvitationCalendarMapping mapping);
Task<MailInvitationCalendarMapping> GetMailInvitationCalendarMappingAsync(Guid accountId, string mailCopyId); Task<MailInvitationCalendarMapping> GetMailInvitationCalendarMappingAsync(Guid accountId, string mailCopyId);
@@ -156,18 +161,33 @@ public class DefaultChangeProcessor(IDatabaseService databaseService,
public Task ChangeMailReadStatusAsync(string mailCopyId, bool isRead) public Task ChangeMailReadStatusAsync(string mailCopyId, bool isRead)
=> MailService.ChangeReadStatusAsync(mailCopyId, isRead); => MailService.ChangeReadStatusAsync(mailCopyId, isRead);
public Task ApplyMailStateUpdatesAsync(IEnumerable<MailCopyStateUpdate> updates)
=> MailService.ApplyMailStateUpdatesAsync(updates);
public Task DeleteAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId) public Task DeleteAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId)
=> MailService.DeleteAssignmentAsync(accountId, mailCopyId, remoteFolderId); => MailService.DeleteAssignmentAsync(accountId, mailCopyId, remoteFolderId);
public Task DeleteAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments)
=> MailService.DeleteAssignmentsAsync(accountId, assignments);
public Task DeleteMailAsync(Guid accountId, string mailId) public Task DeleteMailAsync(Guid accountId, string mailId)
=> MailService.DeleteMailAsync(accountId, mailId); => MailService.DeleteMailAsync(accountId, mailId);
public Task DeleteMailsAsync(Guid accountId, IEnumerable<string> mailIds)
=> MailService.DeleteMailsAsync(accountId, mailIds);
public Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package) public Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package)
=> MailService.CreateMailAsync(accountId, package); => MailService.CreateMailAsync(accountId, package);
public Task CreateMailsAsync(Guid accountId, IReadOnlyList<NewMailItemPackage> packages)
=> MailService.CreateMailsAsync(accountId, packages);
public Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package) public Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package)
=> MailService.CreateMailRawAsync(account, mailItemFolder, package); => MailService.CreateMailRawAsync(account, mailItemFolder, package);
public Task CreateAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments)
=> MailService.CreateAssignmentsAsync(accountId, assignments);
public Task<bool> MapLocalDraftAsync(Guid accountId, Guid localDraftCopyUniqueId, string newMailCopyId, string newDraftId, string newThreadId) public Task<bool> MapLocalDraftAsync(Guid accountId, Guid localDraftCopyUniqueId, string newMailCopyId, string newDraftId, string newThreadId)
=> MailService.MapLocalDraftAsync(accountId, localDraftCopyUniqueId, newMailCopyId, newDraftId, newThreadId); => MailService.MapLocalDraftAsync(accountId, localDraftCopyUniqueId, newMailCopyId, newDraftId, newThreadId);
+163 -52
View File
@@ -1050,6 +1050,11 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
{ {
_logger.Debug("Processing delta change {HistoryId} for {Name}", listHistoryResponse.HistoryId.GetValueOrDefault(), Account.Name); _logger.Debug("Processing delta change {HistoryId} for {Name}", listHistoryResponse.HistoryId.GetValueOrDefault(), Account.Name);
var pendingStateUpdates = new List<MailCopyStateUpdate>();
var pendingAssignmentCreates = new Dictionary<string, MailFolderAssignmentUpdate>(StringComparer.Ordinal);
var pendingAssignmentDeletes = new Dictionary<string, MailFolderAssignmentUpdate>(StringComparer.Ordinal);
var deletedMessageIds = new HashSet<string>(StringComparer.Ordinal);
foreach (var history in listHistoryResponse.History) foreach (var history in listHistoryResponse.History)
{ {
// Handle label additions. // Handle label additions.
@@ -1057,7 +1062,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
{ {
foreach (var addedLabel in history.LabelsAdded) foreach (var addedLabel in history.LabelsAdded)
{ {
await HandleLabelAssignmentAsync(addedLabel); await HandleLabelAssignmentAsync(addedLabel, pendingStateUpdates, pendingAssignmentCreates, pendingAssignmentDeletes).ConfigureAwait(false);
} }
} }
@@ -1066,7 +1071,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
{ {
foreach (var removedLabel in history.LabelsRemoved) foreach (var removedLabel in history.LabelsRemoved)
{ {
await HandleLabelRemovalAsync(removedLabel); await HandleLabelRemovalAsync(removedLabel, pendingStateUpdates, pendingAssignmentCreates, pendingAssignmentDeletes).ConfigureAwait(false);
} }
} }
@@ -1079,36 +1084,108 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
_logger.Debug("Processing message deletion for {MessageId}", messageId); _logger.Debug("Processing message deletion for {MessageId}", messageId);
await _gmailChangeProcessor.DeleteMailAsync(Account.Id, messageId).ConfigureAwait(false); deletedMessageIds.Add(messageId);
} }
} }
} }
if (pendingStateUpdates.Count > 0)
{
await _gmailChangeProcessor.ApplyMailStateUpdatesAsync(pendingStateUpdates).ConfigureAwait(false);
}
if (pendingAssignmentCreates.Count > 0)
{
await _gmailChangeProcessor.CreateAssignmentsAsync(Account.Id, pendingAssignmentCreates.Values.ToList()).ConfigureAwait(false);
}
if (pendingAssignmentDeletes.Count > 0)
{
await _gmailChangeProcessor.DeleteAssignmentsAsync(Account.Id, pendingAssignmentDeletes.Values.ToList()).ConfigureAwait(false);
}
if (deletedMessageIds.Count > 0)
{
await _gmailChangeProcessor.DeleteMailsAsync(Account.Id, deletedMessageIds).ConfigureAwait(false);
}
} }
private async Task HandleArchiveAssignmentAsync(string archivedMessageId) private static string GetAssignmentChangeKey(string messageId, string labelId)
=> $"{messageId}\u001f{labelId}";
private static void QueueAssignmentChange(
Dictionary<string, MailFolderAssignmentUpdate> creates,
Dictionary<string, MailFolderAssignmentUpdate> deletes,
MailFolderAssignmentUpdate assignment,
bool shouldCreate)
{ {
if (assignment == null ||
string.IsNullOrWhiteSpace(assignment.MailCopyId) ||
string.IsNullOrWhiteSpace(assignment.RemoteFolderId))
{
return;
}
var key = GetAssignmentChangeKey(assignment.MailCopyId, assignment.RemoteFolderId);
if (shouldCreate)
{
deletes.Remove(key);
creates[key] = assignment;
}
else
{
creates.Remove(key);
deletes[key] = assignment;
}
}
private async Task HandleArchiveAssignmentAsync(
string archivedMessageId,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentCreates,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentDeletes)
{
if (!archiveFolderId.HasValue)
return;
// Ignore if the message is already in the archive. // Ignore if the message is already in the archive.
bool archived = await _gmailChangeProcessor.IsMailExistsInFolderAsync(archivedMessageId, archiveFolderId.Value); bool archived = await _gmailChangeProcessor.IsMailExistsInFolderAsync(archivedMessageId, archiveFolderId.Value).ConfigureAwait(false);
if (archived) return; if (archived) return;
_logger.Debug("Processing archive assignment for message {Id}", archivedMessageId); _logger.Debug("Processing archive assignment for message {Id}", archivedMessageId);
QueueAssignmentChange(
await _gmailChangeProcessor.CreateAssignmentAsync(Account.Id, archivedMessageId, ServiceConstants.ARCHIVE_LABEL_ID).ConfigureAwait(false); pendingAssignmentCreates,
pendingAssignmentDeletes,
new MailFolderAssignmentUpdate(archivedMessageId, ServiceConstants.ARCHIVE_LABEL_ID),
shouldCreate: true);
} }
private async Task HandleUnarchiveAssignmentAsync(string unarchivedMessageId) private async Task HandleUnarchiveAssignmentAsync(
string unarchivedMessageId,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentCreates,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentDeletes)
{ {
if (!archiveFolderId.HasValue)
return;
// Ignore if the message is not in the archive. // Ignore if the message is not in the archive.
bool archived = await _gmailChangeProcessor.IsMailExistsInFolderAsync(unarchivedMessageId, archiveFolderId.Value); bool archived = await _gmailChangeProcessor.IsMailExistsInFolderAsync(unarchivedMessageId, archiveFolderId.Value).ConfigureAwait(false);
if (!archived) return; if (!archived) return;
_logger.Debug("Processing un-archive assignment for message {Id}", unarchivedMessageId); _logger.Debug("Processing un-archive assignment for message {Id}", unarchivedMessageId);
QueueAssignmentChange(
await _gmailChangeProcessor.DeleteAssignmentAsync(Account.Id, unarchivedMessageId, ServiceConstants.ARCHIVE_LABEL_ID).ConfigureAwait(false); pendingAssignmentCreates,
pendingAssignmentDeletes,
new MailFolderAssignmentUpdate(unarchivedMessageId, ServiceConstants.ARCHIVE_LABEL_ID),
shouldCreate: false);
} }
private async Task HandleLabelAssignmentAsync(HistoryLabelAdded addedLabel) private async Task HandleLabelAssignmentAsync(
HistoryLabelAdded addedLabel,
List<MailCopyStateUpdate> pendingStateUpdates,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentCreates,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentDeletes)
{ {
var messageId = addedLabel.Message.Id; var messageId = addedLabel.Message.Id;
@@ -1119,23 +1196,31 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
// ARCHIVE is a virtual folder - handle it separately // ARCHIVE is a virtual folder - handle it separately
if (labelId == ServiceConstants.ARCHIVE_LABEL_ID) if (labelId == ServiceConstants.ARCHIVE_LABEL_ID)
{ {
await HandleArchiveAssignmentAsync(messageId).ConfigureAwait(false); await HandleArchiveAssignmentAsync(messageId, pendingAssignmentCreates, pendingAssignmentDeletes).ConfigureAwait(false);
continue; continue;
} }
// When UNREAD label is added mark the message as un-read. // When UNREAD label is added mark the message as un-read.
if (labelId == ServiceConstants.UNREAD_LABEL_ID) if (labelId == ServiceConstants.UNREAD_LABEL_ID)
await _gmailChangeProcessor.ChangeMailReadStatusAsync(messageId, false).ConfigureAwait(false); pendingStateUpdates.Add(new MailCopyStateUpdate(messageId, IsRead: false));
// When STARRED label is added mark the message as flagged. // When STARRED label is added mark the message as flagged.
if (labelId == ServiceConstants.STARRED_LABEL_ID) if (labelId == ServiceConstants.STARRED_LABEL_ID)
await _gmailChangeProcessor.ChangeFlagStatusAsync(messageId, true).ConfigureAwait(false); pendingStateUpdates.Add(new MailCopyStateUpdate(messageId, IsFlagged: true));
await _gmailChangeProcessor.CreateAssignmentAsync(Account.Id, messageId, labelId).ConfigureAwait(false); QueueAssignmentChange(
pendingAssignmentCreates,
pendingAssignmentDeletes,
new MailFolderAssignmentUpdate(messageId, labelId),
shouldCreate: true);
} }
} }
private async Task HandleLabelRemovalAsync(HistoryLabelRemoved removedLabel) private async Task HandleLabelRemovalAsync(
HistoryLabelRemoved removedLabel,
List<MailCopyStateUpdate> pendingStateUpdates,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentCreates,
Dictionary<string, MailFolderAssignmentUpdate> pendingAssignmentDeletes)
{ {
var messageId = removedLabel.Message.Id; var messageId = removedLabel.Message.Id;
@@ -1146,20 +1231,23 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
// ARCHIVE is a virtual folder - handle it separately // ARCHIVE is a virtual folder - handle it separately
if (labelId == ServiceConstants.ARCHIVE_LABEL_ID) if (labelId == ServiceConstants.ARCHIVE_LABEL_ID)
{ {
await HandleUnarchiveAssignmentAsync(messageId).ConfigureAwait(false); await HandleUnarchiveAssignmentAsync(messageId, pendingAssignmentCreates, pendingAssignmentDeletes).ConfigureAwait(false);
continue; continue;
} }
// When UNREAD label is removed mark the message as read. // When UNREAD label is removed mark the message as read.
if (labelId == ServiceConstants.UNREAD_LABEL_ID) if (labelId == ServiceConstants.UNREAD_LABEL_ID)
await _gmailChangeProcessor.ChangeMailReadStatusAsync(messageId, true).ConfigureAwait(false); pendingStateUpdates.Add(new MailCopyStateUpdate(messageId, IsRead: true));
// When STARRED label is removed mark the message as un-flagged. // When STARRED label is removed mark the message as un-flagged.
if (labelId == ServiceConstants.STARRED_LABEL_ID) if (labelId == ServiceConstants.STARRED_LABEL_ID)
await _gmailChangeProcessor.ChangeFlagStatusAsync(messageId, false).ConfigureAwait(false); pendingStateUpdates.Add(new MailCopyStateUpdate(messageId, IsFlagged: false));
// For other labels remove the mail assignment. QueueAssignmentChange(
await _gmailChangeProcessor.DeleteAssignmentAsync(Account.Id, messageId, labelId).ConfigureAwait(false); pendingAssignmentCreates,
pendingAssignmentDeletes,
new MailFolderAssignmentUpdate(messageId, labelId),
shouldCreate: false);
} }
} }
@@ -1542,6 +1630,8 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
await Task.WhenAll(batchTasks).ConfigureAwait(false); await Task.WhenAll(batchTasks).ConfigureAwait(false);
// Process all downloaded messages // Process all downloaded messages
var pendingPackages = new List<NewMailItemPackage>();
foreach (var gmailMessage in downloadedMessages) foreach (var gmailMessage in downloadedMessages)
{ {
try try
@@ -1552,12 +1642,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
var packages = await CreateNewMailPackagesAsync(gmailMessage, null, cancellationToken).ConfigureAwait(false); var packages = await CreateNewMailPackagesAsync(gmailMessage, null, cancellationToken).ConfigureAwait(false);
if (packages != null) if (packages != null)
{ pendingPackages.AddRange(packages);
foreach (var package in packages)
{
await _gmailChangeProcessor.CreateMailAsync(Account.Id, package).ConfigureAwait(false);
}
}
// Update sync identifier if available // Update sync identifier if available
if (gmailMessage.HistoryId.HasValue) if (gmailMessage.HistoryId.HasValue)
@@ -1570,6 +1655,11 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
_logger.Error(ex, "Failed to process downloaded message {MessageId}", gmailMessage.Id); _logger.Error(ex, "Failed to process downloaded message {MessageId}", gmailMessage.Id);
} }
} }
if (pendingPackages.Count > 0)
{
await _gmailChangeProcessor.CreateMailsAsync(Account.Id, pendingPackages).ConfigureAwait(false);
}
} }
} }
@@ -1592,12 +1682,9 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
// Create mail packages from metadata // Create mail packages from metadata
var packages = await CreateNewMailPackagesAsync(gmailMessage, null, cancellationToken).ConfigureAwait(false); var packages = await CreateNewMailPackagesAsync(gmailMessage, null, cancellationToken).ConfigureAwait(false);
if (packages != null) if (packages != null && packages.Count > 0)
{ {
foreach (var package in packages) await _gmailChangeProcessor.CreateMailsAsync(Account.Id, packages).ConfigureAwait(false);
{
await _gmailChangeProcessor.CreateMailAsync(Account.Id, package).ConfigureAwait(false);
}
} }
// Update sync identifier if available // Update sync identifier if available
@@ -1897,9 +1984,19 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
if (historyId == null) return false; if (historyId == null) return false;
var newHistoryId = historyId.Value; var newHistoryId = historyId.Value;
var currentSynchronizationIdentifier = Account.SynchronizationDeltaIdentifier;
return Account.SynchronizationDeltaIdentifier == null || if (string.IsNullOrWhiteSpace(currentSynchronizationIdentifier))
(ulong.TryParse(Account.SynchronizationDeltaIdentifier, out ulong currentIdentifier) && newHistoryId > currentIdentifier); return true;
if (!ulong.TryParse(currentSynchronizationIdentifier, out ulong currentIdentifier))
{
_logger.Warning("Current Gmail history ID '{HistoryId}' is invalid for {Name}. Replacing it with {NewHistoryId}.",
currentSynchronizationIdentifier, Account.Name, newHistoryId);
return true;
}
return newHistoryId > currentIdentifier;
} }
private async Task UpdateAccountSyncIdentifierAsync(ulong? historyId) private async Task UpdateAccountSyncIdentifierAsync(ulong? historyId)
@@ -1932,12 +2029,9 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
// Create mail packages from the downloaded message // Create mail packages from the downloaded message
var packages = await CreateNewMailPackagesAsync(gmailMessage, null, cancellationToken).ConfigureAwait(false); var packages = await CreateNewMailPackagesAsync(gmailMessage, null, cancellationToken).ConfigureAwait(false);
if (packages != null) if (packages != null && packages.Count > 0)
{ {
foreach (var package in packages) await _gmailChangeProcessor.CreateMailsAsync(Account.Id, packages).ConfigureAwait(false);
{
await _gmailChangeProcessor.CreateMailAsync(Account.Id, package).ConfigureAwait(false);
}
} }
await UpdateAccountSyncIdentifierAsync(gmailMessage.HistoryId).ConfigureAwait(false); await UpdateAccountSyncIdentifierAsync(gmailMessage.HistoryId).ConfigureAwait(false);
@@ -1989,25 +2083,27 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
switch (bundle.UIChangeRequest) switch (bundle.UIChangeRequest)
{ {
case BatchMarkReadRequest batchMarkReadRequest: case BatchMarkReadRequest batchMarkReadRequest:
foreach (var request in batchMarkReadRequest) await _gmailChangeProcessor.ApplyMailStateUpdatesAsync(
{ batchMarkReadRequest.Select(request => new MailCopyStateUpdate(request.Item.Id, IsRead: request.IsRead)))
await _gmailChangeProcessor.ChangeMailReadStatusAsync(request.Item.Id, request.IsRead).ConfigureAwait(false); .ConfigureAwait(false);
}
break; break;
case MarkReadRequest markReadRequest: case MarkReadRequest markReadRequest:
await _gmailChangeProcessor.ChangeMailReadStatusAsync(markReadRequest.Item.Id, markReadRequest.IsRead).ConfigureAwait(false); await _gmailChangeProcessor.ApplyMailStateUpdatesAsync(
[new MailCopyStateUpdate(markReadRequest.Item.Id, IsRead: markReadRequest.IsRead)])
.ConfigureAwait(false);
break; break;
case BatchChangeFlagRequest batchChangeFlagRequest: case BatchChangeFlagRequest batchChangeFlagRequest:
foreach (var request in batchChangeFlagRequest) await _gmailChangeProcessor.ApplyMailStateUpdatesAsync(
{ batchChangeFlagRequest.Select(request => new MailCopyStateUpdate(request.Item.Id, IsFlagged: request.IsFlagged)))
await _gmailChangeProcessor.ChangeFlagStatusAsync(request.Item.Id, request.IsFlagged).ConfigureAwait(false); .ConfigureAwait(false);
}
break; break;
case ChangeFlagRequest changeFlagRequest: case ChangeFlagRequest changeFlagRequest:
await _gmailChangeProcessor.ChangeFlagStatusAsync(changeFlagRequest.Item.Id, changeFlagRequest.IsFlagged).ConfigureAwait(false); await _gmailChangeProcessor.ApplyMailStateUpdatesAsync(
[new MailCopyStateUpdate(changeFlagRequest.Item.Id, IsFlagged: changeFlagRequest.IsFlagged)])
.ConfigureAwait(false);
break; break;
} }
} }
@@ -2065,16 +2161,31 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
} }
var existingAfterDownload = await _gmailChangeProcessor.AreMailsExistsAsync(addedArchiveIds).ConfigureAwait(false); var existingAfterDownload = await _gmailChangeProcessor.AreMailsExistsAsync(addedArchiveIds).ConfigureAwait(false);
var pendingArchiveCreates = new Dictionary<string, MailFolderAssignmentUpdate>(StringComparer.Ordinal);
var pendingArchiveDeletes = new Dictionary<string, MailFolderAssignmentUpdate>(StringComparer.Ordinal);
foreach (var archiveAddedItem in existingAfterDownload) foreach (var archiveAddedItem in existingAfterDownload)
{ {
await HandleArchiveAssignmentAsync(archiveAddedItem).ConfigureAwait(false); await HandleArchiveAssignmentAsync(archiveAddedItem, pendingArchiveCreates, pendingArchiveDeletes).ConfigureAwait(false);
}
if (pendingArchiveCreates.Count > 0)
{
await _gmailChangeProcessor.CreateAssignmentsAsync(Account.Id, pendingArchiveCreates.Values.ToList()).ConfigureAwait(false);
} }
} }
var pendingArchiveRemovals = new Dictionary<string, MailFolderAssignmentUpdate>(StringComparer.Ordinal);
var pendingArchiveCreateOverrides = new Dictionary<string, MailFolderAssignmentUpdate>(StringComparer.Ordinal);
foreach (var unAarchivedRemovedItem in removedArchiveIds) foreach (var unAarchivedRemovedItem in removedArchiveIds)
{ {
await HandleUnarchiveAssignmentAsync(unAarchivedRemovedItem).ConfigureAwait(false); await HandleUnarchiveAssignmentAsync(unAarchivedRemovedItem, pendingArchiveCreateOverrides, pendingArchiveRemovals).ConfigureAwait(false);
}
if (pendingArchiveRemovals.Count > 0)
{
await _gmailChangeProcessor.DeleteAssignmentsAsync(Account.Id, pendingArchiveRemovals.Values.ToList()).ConfigureAwait(false);
} }
} }
@@ -21,6 +21,8 @@ namespace Wino.Mail.ViewModels.Collections;
public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsChangedMessage> public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsChangedMessage>
{ {
private const int UiMutationBatchSize = 40;
// We cache each mail copy id for faster access on updates. // We cache each mail copy id for faster access on updates.
// If the item provider here for update or removal doesn't exist here // If the item provider here for update or removal doesn't exist here
// we can ignore the operation. // we can ignore the operation.
@@ -763,18 +765,21 @@ public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsC
// Execute all updates in a single UI thread call // Execute all updates in a single UI thread call
if (itemsToUpdate.Count > 0) if (itemsToUpdate.Count > 0)
{ {
await ExecuteUIThread(() => foreach (var updateBatch in itemsToUpdate.Chunk(UiMutationBatchSize))
{ {
foreach (var (existing, updated) in itemsToUpdate) await ExecuteUIThread(() =>
{ {
UpdateUniqueIdHashes(existing, false); foreach (var (existing, updated) in updateBatch)
existing.UpdateFrom(updated); {
UpdateUniqueIdHashes(existing, true); UpdateUniqueIdHashes(existing, false);
} existing.UpdateFrom(updated);
}); UpdateUniqueIdHashes(existing, true);
}
});
}
} }
// Group items by their grouping key and add them in a single UI thread call // Group items by their grouping key and add them in bounded UI thread calls.
if (itemsToAdd.Count > 0) if (itemsToAdd.Count > 0)
{ {
var groupedItems = await Task.Run(() => itemsToAdd var groupedItems = await Task.Run(() => itemsToAdd
@@ -787,32 +792,35 @@ public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsC
}) })
.ToList()).ConfigureAwait(false); .ToList()).ConfigureAwait(false);
await ExecuteUIThread(() => foreach (var groupedItem in groupedItems)
{ {
foreach (var groupedItem in groupedItems) var groupKey = groupedItem.Key;
var groupItems = groupedItem.Items;
foreach (var groupBatch in groupItems.Chunk(UiMutationBatchSize))
{ {
var groupKey = groupedItem.Key; await ExecuteUIThread(() =>
var groupItems = groupedItem.Items;
// Update caches first
foreach (var item in groupItems)
{ {
UpdateUniqueIdHashes(item, true); // Update caches first so lookup helpers remain consistent during inserts.
UpdateThreadIdCache(item, true); foreach (var item in groupBatch)
}
foreach (var item in groupItems)
{
_mailItemSource.InsertItem(groupKey, listComparer, item, listComparer);
var targetGroup = _mailItemSource.FirstGroupByKeyOrDefault(groupKey);
if (targetGroup != null)
{ {
_itemToGroupMap[item] = targetGroup; UpdateUniqueIdHashes(item, true);
UpdateThreadIdCache(item, true);
} }
}
foreach (var item in groupBatch)
{
_mailItemSource.InsertItem(groupKey, listComparer, item, listComparer);
var targetGroup = _mailItemSource.FirstGroupByKeyOrDefault(groupKey);
if (targetGroup != null)
{
_itemToGroupMap[item] = targetGroup;
}
}
});
} }
}); }
} }
} }
@@ -972,20 +980,23 @@ public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsC
if (updates.Count == 0) if (updates.Count == 0)
return; return;
await ExecuteUIThread(() => foreach (var updateBatch in updates.Chunk(UiMutationBatchSize))
{ {
foreach (var update in updates) await ExecuteUIThread(() =>
{ {
var existingItem = update.ItemContainer.ItemViewModel; foreach (var update in updateBatch)
var appliedChanges = existingItem.ApplyStateChanges(update.UpdatedState.IsRead, update.UpdatedState.IsFlagged);
existingItem.IsBusy = mailUpdateSource == EntityUpdateSource.ClientUpdated;
if (update.ItemContainer.ThreadViewModel != null && appliedChanges != MailCopyChangeFlags.None)
{ {
update.ItemContainer.ThreadViewModel.NotifyMailItemUpdated(existingItem, appliedChanges); var existingItem = update.ItemContainer.ItemViewModel;
var appliedChanges = existingItem.ApplyStateChanges(update.UpdatedState.IsRead, update.UpdatedState.IsFlagged);
existingItem.IsBusy = mailUpdateSource == EntityUpdateSource.ClientUpdated;
if (update.ItemContainer.ThreadViewModel != null && appliedChanges != MailCopyChangeFlags.None)
{
update.ItemContainer.ThreadViewModel.NotifyMailItemUpdated(existingItem, appliedChanges);
}
} }
} });
}); }
} }
private async Task UpdateMailCopiesInternalAsync(IEnumerable<MailCopy> updatedMailCopies, EntityUpdateSource mailUpdateSource, MailCopyChangeFlags changedProperties) private async Task UpdateMailCopiesInternalAsync(IEnumerable<MailCopy> updatedMailCopies, EntityUpdateSource mailUpdateSource, MailCopyChangeFlags changedProperties)
@@ -1018,22 +1029,25 @@ public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsC
return; return;
} }
await ExecuteUIThread(() => foreach (var updateBatch in updates.Chunk(UiMutationBatchSize))
{ {
foreach (var update in updates) await ExecuteUIThread(() =>
{ {
var updatedMail = update.UpdatedMail; foreach (var update in updateBatch)
var itemContainer = update.ItemContainer;
var existingItem = itemContainer.ItemViewModel;
var appliedChanges = existingItem.UpdateFrom(updatedMail, changedProperties);
existingItem.IsBusy = mailUpdateSource == EntityUpdateSource.ClientUpdated;
if (itemContainer.ThreadViewModel != null && appliedChanges != MailCopyChangeFlags.None)
{ {
itemContainer.ThreadViewModel.NotifyMailItemUpdated(existingItem, appliedChanges); var updatedMail = update.UpdatedMail;
var itemContainer = update.ItemContainer;
var existingItem = itemContainer.ItemViewModel;
var appliedChanges = existingItem.UpdateFrom(updatedMail, changedProperties);
existingItem.IsBusy = mailUpdateSource == EntityUpdateSource.ClientUpdated;
if (itemContainer.ThreadViewModel != null && appliedChanges != MailCopyChangeFlags.None)
{
itemContainer.ThreadViewModel.NotifyMailItemUpdated(existingItem, appliedChanges);
}
} }
} });
}); }
} }
public MailItemViewModel GetFirst() => AllItems.ElementAtOrDefault(0); public MailItemViewModel GetFirst() => AllItems.ElementAtOrDefault(0);
@@ -10,6 +10,7 @@ using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using MimeKit; using MimeKit;
using MimeKit.Cryptography; using MimeKit.Cryptography;
using Serilog;
using Wino.Core.Domain; using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Mail; using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Entities.Shared;
@@ -37,9 +38,11 @@ public partial class ComposePageViewModel : MailBaseViewModel,
public event EventHandler CloseRequested; public event EventHandler CloseRequested;
private static readonly TimeSpan LocalDraftRetryGracePeriod = TimeSpan.FromSeconds(15); private static readonly TimeSpan LocalDraftRetryGracePeriod = TimeSpan.FromSeconds(15);
private const string MimeFileName = "mail.eml";
public Func<Task<string>> GetHTMLBodyFunction; public Func<Task<string>> GetHTMLBodyFunction;
public Func<string, Task> RenderHtmlBodyAsyncFunc { get; set; } public Func<string, Task> RenderHtmlBodyAsyncFunc { get; set; }
public Func<string, Task<bool>> SaveHTMLasPDFFunc { get; set; }
public override async Task KeyboardShortcutHook(KeyboardShortcutTriggerDetails args) public override async Task KeyboardShortcutHook(KeyboardShortcutTriggerDetails args)
{ {
@@ -440,6 +443,77 @@ public partial class ComposePageViewModel : MailBaseViewModel,
await _mimeFileService.SaveMimeMessageAsync(CurrentMailDraftItem.MailCopy.FileId, CurrentMimeMessage, ComposingAccount.Id).ConfigureAwait(false); await _mimeFileService.SaveMimeMessageAsync(CurrentMailDraftItem.MailCopy.FileId, CurrentMimeMessage, ComposingAccount.Id).ConfigureAwait(false);
} }
public async Task ExportAsPdfAsync()
{
if (SaveHTMLasPDFFunc == null)
{
return;
}
try
{
var pickedFilePath = await _dialogService.PickFilePathAsync($"{GetSuggestedExportFileName()}.pdf").ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(pickedFilePath))
{
return;
}
bool isSaved = await SaveHTMLasPDFFunc(pickedFilePath).ConfigureAwait(false);
if (isSaved)
{
_dialogService.InfoBarMessage(
Translator.Info_PDFSaveSuccessTitle,
string.Format(Translator.Info_PDFSaveSuccessMessage, pickedFilePath),
InfoBarMessageType.Success);
}
}
catch (Exception ex)
{
Log.Error(ex, "Failed to save compose draft as PDF.");
_dialogService.InfoBarMessage(Translator.Info_PDFSaveFailedTitle, ex.Message, InfoBarMessageType.Error);
}
}
public async Task ExportAsEmlAsync()
{
if (CurrentMailDraftItem?.MailCopy == null || ComposingAccount == null)
{
_dialogService.InfoBarMessage(Translator.Info_ComposerMissingMIMETitle, Translator.Info_ComposerMissingMIMEMessage, InfoBarMessageType.Error);
return;
}
try
{
await UpdateMimeChangesAsync().ConfigureAwait(false);
var pickedFilePath = await _dialogService.PickFilePathAsync($"{GetSuggestedExportFileName()}.eml").ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(pickedFilePath))
{
return;
}
var resourcePath = await _mimeFileService
.GetMimeResourcePathAsync(ComposingAccount.Id, CurrentMailDraftItem.MailCopy.FileId)
.ConfigureAwait(false);
var sourceFilePath = Path.Combine(resourcePath, MimeFileName);
File.Copy(sourceFilePath, pickedFilePath, true);
_dialogService.InfoBarMessage(
Translator.Info_EMLSaveSuccessTitle,
string.Format(Translator.Info_EMLSaveSuccessMessage, pickedFilePath),
InfoBarMessageType.Success);
}
catch (Exception ex)
{
Log.Error(ex, "Failed to save compose draft as EML.");
_dialogService.InfoBarMessage(Translator.Info_EMLSaveFailedTitle, ex.Message, InfoBarMessageType.Error);
}
}
private async Task UpdateMailCopyAsync() private async Task UpdateMailCopyAsync()
{ {
CurrentMailDraftItem.Subject = CurrentMimeMessage.Subject; CurrentMailDraftItem.Subject = CurrentMimeMessage.Subject;
@@ -879,6 +953,29 @@ public partial class ComposePageViewModel : MailBaseViewModel,
list.Add(new MailboxAddress(item.Name, item.Address)); list.Add(new MailboxAddress(item.Name, item.Address));
} }
private string GetSuggestedExportFileName()
{
var subject = string.IsNullOrWhiteSpace(Subject) ? Translator.MailItemNoSubject : Subject;
return SanitizeFileNamePart(subject);
}
private static string SanitizeFileNamePart(string value)
{
var invalidCharacters = Path.GetInvalidFileNameChars();
var sanitizedChars = value.Trim().ToCharArray();
for (var i = 0; i < sanitizedChars.Length; i++)
{
if (Array.IndexOf(invalidCharacters, sanitizedChars[i]) >= 0)
{
sanitizedChars[i] = '_';
}
}
var sanitized = new string(sanitizedChars).Trim();
return string.IsNullOrWhiteSpace(sanitized) ? "email" : sanitized;
}
private async Task<(DraftCreationReason reason, MailCopy referenceMailCopy)> ResolveRetryDraftContextAsync() private async Task<(DraftCreationReason reason, MailCopy referenceMailCopy)> ResolveRetryDraftContextAsync()
{ {
if (CurrentMimeMessage == null || CurrentMailDraftItem?.MailCopy?.AssignedAccount == null) if (CurrentMimeMessage == null || CurrentMailDraftItem?.MailCopy?.AssignedAccount == null)
+17 -2
View File
@@ -217,6 +217,8 @@ public partial class MailListPageViewModel : MailBaseViewModel,
{ {
base.OnNavigatedTo(mode, parameters); base.OnNavigatedTo(mode, parameters);
PreferencesService.PreferenceChanged -= PreferencesServiceChanged;
PreferencesService.PreferenceChanged += PreferencesServiceChanged;
MailCollection.ItemSelectionChanged += MailItemSelectionChanged; MailCollection.ItemSelectionChanged += MailItemSelectionChanged;
} }
@@ -224,6 +226,7 @@ public partial class MailListPageViewModel : MailBaseViewModel,
{ {
base.OnNavigatedFrom(mode, parameters); base.OnNavigatedFrom(mode, parameters);
PreferencesService.PreferenceChanged -= PreferencesServiceChanged;
MailCollection.ItemSelectionChanged -= MailItemSelectionChanged; MailCollection.ItemSelectionChanged -= MailItemSelectionChanged;
await MailCollection.ClearAsync(); await MailCollection.ClearAsync();
@@ -296,7 +299,7 @@ public partial class MailListPageViewModel : MailBaseViewModel,
public bool IsJunkFolder => ActiveFolder?.SpecialFolderType == SpecialFolderType.Junk; public bool IsJunkFolder => ActiveFolder?.SpecialFolderType == SpecialFolderType.Junk;
public bool IsCategoryView => ActiveFolder is IMailCategoryMenuItem or IMergedMailCategoryMenuItem; public bool IsCategoryView => ActiveFolder is IMailCategoryMenuItem or IMergedMailCategoryMenuItem;
public bool IsSyncButtonVisible => !IsCategoryView; public bool IsSyncButtonVisible => !IsCategoryView;
public bool IsEmptyFolderButtonVisible => IsJunkFolder; public bool IsEmptyFolderButtonVisible => IsJunkFolder && PreferencesService.IsShowEmptyJunkFolderEnabled;
public string SelectedMessageText => IsDragInProgress public string SelectedMessageText => IsDragInProgress
? string.Format(Translator.MailsDragging, DraggingItemsCount) ? string.Format(Translator.MailsDragging, DraggingItemsCount)
@@ -386,6 +389,18 @@ public partial class MailListPageViewModel : MailBaseViewModel,
OnPropertyChanged(nameof(IsFolderEmpty)); OnPropertyChanged(nameof(IsFolderEmpty));
} }
private async void PreferencesServiceChanged(object sender, string propertyName)
{
if (propertyName != nameof(IPreferencesService.IsShowEmptyJunkFolderEnabled))
return;
await ExecuteUIThread(() =>
{
OnPropertyChanged(nameof(IsEmptyFolderButtonVisible));
EmptyFolderCommand.NotifyCanExecuteChanged();
});
}
private async void UpdateBarMessage(InfoBarMessageType severity, string title, string message) private async void UpdateBarMessage(InfoBarMessageType severity, string title, string message)
{ {
await ExecuteUIThread(() => await ExecuteUIThread(() =>
@@ -588,7 +603,7 @@ public partial class MailListPageViewModel : MailBaseViewModel,
} }
} }
private bool CanEmptyFolder() => IsJunkFolder && !IsAccountSynchronizerInSynchronization; private bool CanEmptyFolder() => IsEmptyFolderButtonVisible && !IsAccountSynchronizerInSynchronization;
[RelayCommand(CanExecute = nameof(CanLoadMoreItems))] [RelayCommand(CanExecute = nameof(CanLoadMoreItems))]
private async Task LoadMoreItemsAsync() private async Task LoadMoreItemsAsync()
@@ -20,47 +20,18 @@ public partial class SignatureManagementPageViewModel(IMailDialogService dialogS
IAccountService accountService) : MailBaseViewModel IAccountService accountService) : MailBaseViewModel
{ {
public ObservableCollection<AccountSignature> Signatures { get; set; } = []; public ObservableCollection<AccountSignature> Signatures { get; set; } = [];
private bool isLoaded;
[ObservableProperty] [ObservableProperty]
private bool isSignatureEnabled; public partial bool IsSignatureEnabled { get; set; }
private int signatureForNewMessagesIndex;
public Guid EmptyGuid { get; } = Guid.Empty; public Guid EmptyGuid { get; } = Guid.Empty;
public int SignatureForNewMessagesIndex [ObservableProperty]
{ public partial AccountSignature SelectedSignatureForNewMessages { get; set; }
get => signatureForNewMessagesIndex;
set
{
if (value == -1)
{
SetProperty(ref signatureForNewMessagesIndex, 0);
}
else
{
SetProperty(ref signatureForNewMessagesIndex, value);
}
}
}
private int signatureForFollowingMessagesIndex; [ObservableProperty]
public partial AccountSignature SelectedSignatureForFollowingMessages { get; set; }
public int SignatureForFollowingMessagesIndex
{
get => signatureForFollowingMessagesIndex;
set
{
if (value == -1)
{
SetProperty(ref signatureForFollowingMessagesIndex, 0);
}
else
{
SetProperty(ref signatureForFollowingMessagesIndex, value);
}
}
}
private MailAccount Account { get; set; } private MailAccount Account { get; set; }
@@ -71,6 +42,7 @@ public partial class SignatureManagementPageViewModel(IMailDialogService dialogS
public override async void OnNavigatedTo(NavigationMode mode, object parameters) public override async void OnNavigatedTo(NavigationMode mode, object parameters)
{ {
base.OnNavigatedTo(mode, parameters); base.OnNavigatedTo(mode, parameters);
isLoaded = false;
if (parameters is Guid accountId) if (parameters is Guid accountId)
Account = await _accountService.GetAccountAsync(accountId); Account = await _accountService.GetAccountAsync(accountId);
@@ -78,36 +50,43 @@ public partial class SignatureManagementPageViewModel(IMailDialogService dialogS
if (Account == null) return; if (Account == null) return;
var dbSignatures = await _signatureService.GetSignaturesAsync(Account.Id); var dbSignatures = await _signatureService.GetSignaturesAsync(Account.Id);
IsSignatureEnabled = Account.Preferences.IsSignatureEnabled; var noneSignature = new AccountSignature { Id = EmptyGuid, Name = Translator.SettingsSignature_NoneSignatureName };
var signatureForNewMessages = dbSignatures.FirstOrDefault(x => x.Id == Account.Preferences.SignatureIdForNewMessages) ?? noneSignature;
var signatureForFollowingMessages = dbSignatures.FirstOrDefault(x => x.Id == Account.Preferences.SignatureIdForFollowingMessages) ?? noneSignature;
Signatures.Clear(); await ExecuteUIThread(() =>
Signatures.Add(new AccountSignature { Id = EmptyGuid, Name = Translator.SettingsSignature_NoneSignatureName }); {
dbSignatures.ForEach(Signatures.Add); IsSignatureEnabled = Account.Preferences.IsSignatureEnabled;
SignatureForNewMessagesIndex = Signatures.IndexOf(Signatures.FirstOrDefault(x => x.Id == Account.Preferences.SignatureIdForNewMessages)); Signatures.Clear();
SignatureForFollowingMessagesIndex = Signatures.IndexOf(Signatures.FirstOrDefault(x => x.Id == Account.Preferences.SignatureIdForFollowingMessages)); Signatures.Add(noneSignature);
dbSignatures.ForEach(Signatures.Add);
SelectedSignatureForNewMessages = signatureForNewMessages;
SelectedSignatureForFollowingMessages = signatureForFollowingMessages;
});
isLoaded = true;
} }
protected override async void OnPropertyChanged(PropertyChangedEventArgs e) protected override async void OnPropertyChanged(PropertyChangedEventArgs e)
{ {
base.OnPropertyChanged(e); base.OnPropertyChanged(e);
if (!isLoaded || Account?.Preferences == null) return;
switch (e.PropertyName) switch (e.PropertyName)
{ {
case nameof(IsSignatureEnabled): case nameof(IsSignatureEnabled):
Account.Preferences.IsSignatureEnabled = IsSignatureEnabled; Account.Preferences.IsSignatureEnabled = IsSignatureEnabled;
await _accountService.UpdateAccountAsync(Account); await _accountService.UpdateAccountAsync(Account);
break; break;
case nameof(SignatureForNewMessagesIndex): case nameof(SelectedSignatureForNewMessages):
Account.Preferences.SignatureIdForNewMessages = SignatureForNewMessagesIndex > -1 Account.Preferences.SignatureIdForNewMessages = GetPersistedSignatureId(SelectedSignatureForNewMessages);
&& Signatures[SignatureForNewMessagesIndex].Id != EmptyGuid
? Signatures[SignatureForNewMessagesIndex].Id : null;
await _accountService.UpdateAccountAsync(Account); await _accountService.UpdateAccountAsync(Account);
break; break;
case nameof(SignatureForFollowingMessagesIndex): case nameof(SelectedSignatureForFollowingMessages):
Account.Preferences.SignatureIdForFollowingMessages = SignatureForFollowingMessagesIndex > -1 Account.Preferences.SignatureIdForFollowingMessages = GetPersistedSignatureId(SelectedSignatureForFollowingMessages);
&& Signatures[SignatureForFollowingMessagesIndex].Id != EmptyGuid
? Signatures[SignatureForFollowingMessagesIndex].Id : null;
await _accountService.UpdateAccountAsync(Account); await _accountService.UpdateAccountAsync(Account);
break; break;
} }
@@ -121,7 +100,7 @@ public partial class SignatureManagementPageViewModel(IMailDialogService dialogS
if (dialogResult == null) return; if (dialogResult == null) return;
dialogResult.MailAccountId = Account.Id; dialogResult.MailAccountId = Account.Id;
Signatures.Add(dialogResult); await ExecuteUIThread(() => Signatures.Add(dialogResult));
await _signatureService.CreateSignatureAsync(dialogResult); await _signatureService.CreateSignatureAsync(dialogResult);
} }
@@ -133,18 +112,23 @@ public partial class SignatureManagementPageViewModel(IMailDialogService dialogS
if (dialogResult == null) return; if (dialogResult == null) return;
var indexOfCurrentSignature = Signatures.IndexOf(signatureModel); var indexOfCurrentSignature = Signatures.IndexOf(signatureModel);
var signatureNewMessagesIndex = SignatureForNewMessagesIndex; if (indexOfCurrentSignature < 0) return;
var signatureFollowingMessagesIndex = SignatureForFollowingMessagesIndex;
Signatures[indexOfCurrentSignature] = dialogResult; var wasSelectedForNewMessages = SelectedSignatureForNewMessages?.Id == signatureModel.Id;
var wasSelectedForFollowingMessages = SelectedSignatureForFollowingMessages?.Id == signatureModel.Id;
// Reset selection to point updated signature. dialogResult.MailAccountId = signatureModel.MailAccountId;
// When Item updated/removed index switches to -1. We save index that was used before and update -1 to it.
if (signatureNewMessagesIndex == indexOfCurrentSignature)
SignatureForNewMessagesIndex = indexOfCurrentSignature;
if (signatureFollowingMessagesIndex == indexOfCurrentSignature) await ExecuteUIThread(() =>
SignatureForFollowingMessagesIndex = indexOfCurrentSignature; {
Signatures[indexOfCurrentSignature] = dialogResult;
if (wasSelectedForNewMessages)
SelectedSignatureForNewMessages = dialogResult;
if (wasSelectedForFollowingMessages)
SelectedSignatureForFollowingMessages = dialogResult;
});
await _signatureService.UpdateSignatureAsync(dialogResult); await _signatureService.UpdateSignatureAsync(dialogResult);
} }
@@ -156,7 +140,31 @@ public partial class SignatureManagementPageViewModel(IMailDialogService dialogS
if (!shouldRemove) return; if (!shouldRemove) return;
Signatures.Remove(signatureModel); var shouldResetNewMessagesSignature = SelectedSignatureForNewMessages?.Id == signatureModel.Id;
var shouldResetFollowingMessagesSignature = SelectedSignatureForFollowingMessages?.Id == signatureModel.Id;
await ExecuteUIThread(() =>
{
Signatures.Remove(signatureModel);
var noneSignature = GetNoneSignature();
if (shouldResetNewMessagesSignature)
SelectedSignatureForNewMessages = noneSignature;
if (shouldResetFollowingMessagesSignature)
SelectedSignatureForFollowingMessages = noneSignature;
});
await _signatureService.DeleteSignatureAsync(signatureModel); await _signatureService.DeleteSignatureAsync(signatureModel);
} }
private Guid? GetPersistedSignatureId(AccountSignature signature)
=> signature?.Id is Guid signatureId && signatureId != EmptyGuid
? signatureId
: null;
private AccountSignature GetNoneSignature()
=> Signatures.FirstOrDefault(x => x.Id == EmptyGuid)
?? new AccountSignature { Id = EmptyGuid, Name = Translator.SettingsSignature_NoneSignatureName };
} }
+2
View File
@@ -479,6 +479,8 @@ public partial class App : WinoApplication,
EnsureAppNotificationRegistration(); EnsureAppNotificationRegistration();
await TranslationService.InitializeAsync();
await Services.GetRequiredService<ReleaseLocalAccountDataCleanupService>() await Services.GetRequiredService<ReleaseLocalAccountDataCleanupService>()
.RunIfNeededAsync(); .RunIfNeededAsync();
@@ -1,5 +1,4 @@
using System; using System;
using System.Text.RegularExpressions;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Wino.Core.Domain; using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Mail; using Wino.Core.Domain.Entities.Mail;
@@ -24,9 +23,6 @@ public sealed partial class SignatureEditorDialog : ContentDialog
{ {
InitializeComponent(); InitializeComponent();
SignatureNameTextBox.Text = signatureModel.Name.Trim();
SignatureNameTextBox.Header = string.Format(Translator.SignatureEditorDialog_SignatureName_TitleEdit, signatureModel.Name);
Result = new AccountSignature Result = new AccountSignature
{ {
Id = signatureModel.Id, Id = signatureModel.Id,
@@ -35,6 +31,9 @@ public sealed partial class SignatureEditorDialog : ContentDialog
HtmlBody = signatureModel.HtmlBody HtmlBody = signatureModel.HtmlBody
}; };
SignatureNameTextBox.Text = Result.Name.Trim();
SignatureNameTextBox.Header = string.Format(Translator.SignatureEditorDialog_SignatureName_TitleEdit, Result.Name);
// TODO: Should be added additional logic to enable/disable primary button when webview content changed. // TODO: Should be added additional logic to enable/disable primary button when webview content changed.
IsPrimaryButtonEnabled = true; IsPrimaryButtonEnabled = true;
} }
@@ -51,7 +50,7 @@ public sealed partial class SignatureEditorDialog : ContentDialog
private async void SaveClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args) private async void SaveClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{ {
var newSignature = Regex.Unescape((await WebViewEditor.GetHtmlBodyAsync())!); var newSignature = await WebViewEditor.GetHtmlBodyAsync() ?? string.Empty;
if (Result == null) if (Result == null)
{ {
+1
View File
@@ -9,6 +9,7 @@ const joditConfig = {
"showWordsCounter": false, "showWordsCounter": false,
"showXPathInStatusbar": false, "showXPathInStatusbar": false,
"spellcheck": true, "spellcheck": true,
"defaultActionOnPaste": "insert_as_text",
"link": { "link": {
"processVideoLink": false "processVideoLink": false
}, },
+1 -1
View File
@@ -23,7 +23,7 @@
<Identity <Identity
Name="58272BurakKSE.WinoMailPreview" Name="58272BurakKSE.WinoMailPreview"
Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911" Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911"
Version="2.0.4.0" /> Version="2.0.7.0" />
<mp:PhoneIdentity PhoneProductId="7b7e90e9-cc55-4409-9769-99b4b5ed6e9b" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <mp:PhoneIdentity PhoneProductId="7b7e90e9-cc55-4409-9769-99b4b5ed6e9b" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
@@ -9,6 +9,9 @@ namespace Wino.Mail.WinUI.Services;
public class ConfigurationService : IConfigurationService public class ConfigurationService : IConfigurationService
{ {
public bool Contains(string key)
=> ApplicationData.Current.LocalSettings.Values.ContainsKey(key);
public T Get<T>(string key, T defaultValue = default!) public T Get<T>(string key, T defaultValue = default!)
=> GetInternal(key, ApplicationData.Current.LocalSettings.Values, defaultValue); => GetInternal(key, ApplicationData.Current.LocalSettings.Values, defaultValue);
@@ -233,6 +233,17 @@ public class NotificationBuilder : INotificationBuilder
ShowNotification(builder, "store-update-available"); ShowNotification(builder, "store-update-available");
} }
public void CreateReleaseMigrationNotification()
{
var builder = CreateBuilder();
builder.AddText(Translator.Notifications_ReleaseMigrationTitle);
builder.AddText(Translator.Notifications_ReleaseMigrationMessage);
builder.AddArgument(Constants.ToastModeKey, Constants.ToastModeMail);
builder.AddButton(CreateDismissButton());
ShowNotification(builder, "release-migration-v2");
}
public Task CreateCalendarReminderNotificationAsync(CalendarItem calendarItem, long reminderDurationInSeconds) public Task CreateCalendarReminderNotificationAsync(CalendarItem calendarItem, long reminderDurationInSeconds)
{ {
if (calendarItem == null) if (calendarItem == null)
@@ -111,6 +111,12 @@ public class PreferencesService(IConfigurationService configurationService) : Ob
set => SetPropertyAndSave(nameof(IsHardDeleteProtectionEnabled), value); set => SetPropertyAndSave(nameof(IsHardDeleteProtectionEnabled), value);
} }
public bool IsShowEmptyJunkFolderEnabled
{
get => _configurationService.Get(nameof(IsShowEmptyJunkFolderEnabled), false);
set => SetPropertyAndSave(nameof(IsShowEmptyJunkFolderEnabled), value);
}
public bool IsThreadingEnabled public bool IsThreadingEnabled
{ {
get => _configurationService.Get(nameof(IsThreadingEnabled), true); get => _configurationService.Get(nameof(IsThreadingEnabled), true);
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog; using Serilog;
using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Interfaces;
@@ -14,13 +15,16 @@ public sealed class ReleaseLocalAccountDataCleanupService
private readonly IConfigurationService _configurationService; private readonly IConfigurationService _configurationService;
private readonly IApplicationConfiguration _applicationConfiguration; private readonly IApplicationConfiguration _applicationConfiguration;
private readonly INotificationBuilder _notificationBuilder;
private readonly ILogger _logger = Log.ForContext<ReleaseLocalAccountDataCleanupService>(); private readonly ILogger _logger = Log.ForContext<ReleaseLocalAccountDataCleanupService>();
public ReleaseLocalAccountDataCleanupService(IConfigurationService configurationService, public ReleaseLocalAccountDataCleanupService(IConfigurationService configurationService,
IApplicationConfiguration applicationConfiguration) IApplicationConfiguration applicationConfiguration,
INotificationBuilder notificationBuilder)
{ {
_configurationService = configurationService; _configurationService = configurationService;
_applicationConfiguration = applicationConfiguration; _applicationConfiguration = applicationConfiguration;
_notificationBuilder = notificationBuilder;
} }
public async Task RunIfNeededAsync() public async Task RunIfNeededAsync()
@@ -45,44 +49,70 @@ public sealed class ReleaseLocalAccountDataCleanupService
Path.Combine(publisherPath, LegacyDatabaseFileName) Path.Combine(publisherPath, LegacyDatabaseFileName)
}; };
var hadLegacyData = false;
foreach (var targetPath in cleanupTargets) foreach (var targetPath in cleanupTargets)
{ {
await DeletePathIfExistsAsync(localFolderPath, targetPath).ConfigureAwait(false); hadLegacyData |= await DeletePathIfExistsAsync(targetPath, localFolderPath, publisherPath).ConfigureAwait(false);
} }
_configurationService.Set(CleanupCompletedSettingKey, true); _configurationService.Set(CleanupCompletedSettingKey, true);
if (hadLegacyData)
{
_notificationBuilder.CreateReleaseMigrationNotification();
}
_logger.Information("Completed one-time local account data cleanup for release migration."); _logger.Information("Completed one-time local account data cleanup for release migration.");
} }
private async Task DeletePathIfExistsAsync(string localFolderPath, string targetPath) private async Task<bool> DeletePathIfExistsAsync(string targetPath, params string[] allowedRootPaths)
{ {
try try
{ {
var fullTargetPath = Path.GetFullPath(targetPath); var fullTargetPath = Path.GetFullPath(targetPath);
var fullLocalFolderPath = Path.GetFullPath(localFolderPath); if (!allowedRootPaths.Any(rootPath => IsPathUnderAllowedRoot(fullTargetPath, rootPath)))
if (!fullTargetPath.StartsWith(fullLocalFolderPath, StringComparison.OrdinalIgnoreCase))
{ {
_logger.Warning("Skipped startup cleanup for path outside local folder: {TargetPath}", fullTargetPath); _logger.Warning("Skipped startup cleanup for path outside allowed roots: {TargetPath}", fullTargetPath);
return; return false;
} }
var targetExists = Directory.Exists(fullTargetPath) || File.Exists(fullTargetPath);
if (Directory.Exists(fullTargetPath)) if (Directory.Exists(fullTargetPath))
{ {
await Task.Run(() => Directory.Delete(fullTargetPath, recursive: true)).ConfigureAwait(false); await Task.Run(() => Directory.Delete(fullTargetPath, recursive: true)).ConfigureAwait(false);
_logger.Information("Deleted legacy startup cleanup directory {TargetPath}", fullTargetPath); _logger.Information("Deleted legacy startup cleanup directory {TargetPath}", fullTargetPath);
return; return true;
} }
if (File.Exists(fullTargetPath)) if (File.Exists(fullTargetPath))
{ {
File.Delete(fullTargetPath); File.Delete(fullTargetPath);
_logger.Information("Deleted legacy startup cleanup file {TargetPath}", fullTargetPath); _logger.Information("Deleted legacy startup cleanup file {TargetPath}", fullTargetPath);
return true;
} }
return targetExists;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.Warning(ex, "Failed to delete legacy startup cleanup path {TargetPath}", targetPath); _logger.Warning(ex, "Failed to delete legacy startup cleanup path {TargetPath}", targetPath);
} }
return false;
}
private static bool IsPathUnderAllowedRoot(string fullTargetPath, string rootPath)
{
if (string.IsNullOrWhiteSpace(rootPath))
return false;
var fullRootPath = Path.GetFullPath(rootPath);
var relativePath = Path.GetRelativePath(fullRootPath, fullTargetPath);
return relativePath != "." &&
!relativePath.StartsWith("..", StringComparison.Ordinal) &&
!Path.IsPathRooted(relativePath);
} }
} }
@@ -185,6 +185,17 @@
<coreControls:WinoFontIcon Icon="{x:Bind GetEditorThemeIcon(WebViewEditor.IsEditorDarkMode), Mode=OneWay}" /> <coreControls:WinoFontIcon Icon="{x:Bind GetEditorThemeIcon(WebViewEditor.IsEditorDarkMode), Mode=OneWay}" />
</AppBarButton.Icon> </AppBarButton.Icon>
</AppBarButton> </AppBarButton>
<AppBarButton Label="{x:Bind domain:Translator.MailOperation_SaveAs}">
<AppBarButton.Icon>
<coreControls:WinoFontIcon Icon="Save" />
</AppBarButton.Icon>
<AppBarButton.Flyout>
<coreControls:WinoMenuFlyout Placement="BottomEdgeAlignedRight">
<MenuFlyoutItem Click="ExportPdf_Click" Text="{x:Bind domain:Translator.Buttons_PDF}" />
<MenuFlyoutItem Click="ExportEml_Click" Text="{x:Bind domain:Translator.Buttons_EML}" />
</coreControls:WinoMenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton Command="{x:Bind ViewModel.DiscardCommand}" Label="{x:Bind domain:Translator.Buttons_Discard}"> <AppBarButton Command="{x:Bind ViewModel.DiscardCommand}" Label="{x:Bind domain:Translator.Buttons_Discard}">
<AppBarButton.Icon> <AppBarButton.Icon>
<coreControls:WinoFontIcon Icon="Delete" /> <coreControls:WinoFontIcon Icon="Delete" />
@@ -59,6 +59,17 @@ public sealed partial class ComposePage : ComposePageAbstract,
public ComposePage() public ComposePage()
{ {
InitializeComponent(); InitializeComponent();
ViewModel.SaveHTMLasPDFFunc = async path =>
{
var webView = GetWebView();
if (webView?.CoreWebView2 == null)
{
return false;
}
return await webView.CoreWebView2.PrintToPdfAsync(path, null);
};
ViewModel.CloseRequested += ViewModel_CloseRequested; ViewModel.CloseRequested += ViewModel_CloseRequested;
} }
@@ -495,6 +506,7 @@ public sealed partial class ComposePage : ComposePageAbstract,
FocusManager.GotFocus -= GlobalFocusManagerGotFocus; FocusManager.GotFocus -= GlobalFocusManagerGotFocus;
ComposeAiActionsPanel.CancelPendingOperation(); ComposeAiActionsPanel.CancelPendingOperation();
await ViewModel.UpdateMimeChangesAsync(); await ViewModel.UpdateMimeChangesAsync();
ViewModel.SaveHTMLasPDFFunc = null;
ViewModel.RenderHtmlBodyAsyncFunc = null; ViewModel.RenderHtmlBodyAsyncFunc = null;
DisposeDisposables(); DisposeDisposables();
@@ -565,6 +577,16 @@ public sealed partial class ComposePage : ComposePageAbstract,
} }
} }
private async void ExportPdf_Click(object sender, RoutedEventArgs e)
{
await ViewModel.ExportAsPdfAsync();
}
private async void ExportEml_Click(object sender, RoutedEventArgs e)
{
await ViewModel.ExportAsEmlAsync();
}
protected override void RegisterRecipients() protected override void RegisterRecipients()
{ {
base.RegisterRecipients(); base.RegisterRecipients();
@@ -160,6 +160,10 @@
<ToggleSwitch IsOn="{x:Bind ViewModel.PreferencesService.IsHardDeleteProtectionEnabled, Mode=TwoWay}" /> <ToggleSwitch IsOn="{x:Bind ViewModel.PreferencesService.IsHardDeleteProtectionEnabled, Mode=TwoWay}" />
</controls:SettingsCard> </controls:SettingsCard>
<controls:SettingsCard Description="{x:Bind domain:Translator.SettingsEmptyJunkFolderCommand_Description}" Header="{x:Bind domain:Translator.SettingsEmptyJunkFolderCommand_Title}">
<ToggleSwitch IsOn="{x:Bind ViewModel.PreferencesService.IsShowEmptyJunkFolderEnabled, Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard Description="{x:Bind domain:Translator.SettingsAutoSelectNextItem_Description}" Header="{x:Bind domain:Translator.SettingsAutoSelectNextItem_Title}"> <controls:SettingsCard Description="{x:Bind domain:Translator.SettingsAutoSelectNextItem_Description}" Header="{x:Bind domain:Translator.SettingsAutoSelectNextItem_Title}">
<ToggleSwitch IsOn="{x:Bind ViewModel.PreferencesService.AutoSelectNextItem, Mode=TwoWay}" /> <ToggleSwitch IsOn="{x:Bind ViewModel.PreferencesService.AutoSelectNextItem, Mode=TwoWay}" />
<controls:SettingsCard.HeaderIcon> <controls:SettingsCard.HeaderIcon>
@@ -77,7 +77,7 @@
IsActionIconVisible="False" IsActionIconVisible="False"
IsClickEnabled="False" IsClickEnabled="False"
IsEnabled="{x:Bind ViewModel.IsSignatureEnabled, Mode=OneWay}"> IsEnabled="{x:Bind ViewModel.IsSignatureEnabled, Mode=OneWay}">
<ComboBox ItemsSource="{x:Bind ViewModel.Signatures}" SelectedIndex="{x:Bind ViewModel.SignatureForNewMessagesIndex, Mode=TwoWay}"> <ComboBox ItemsSource="{x:Bind ViewModel.Signatures}" SelectedItem="{x:Bind ViewModel.SelectedSignatureForNewMessages, Mode=TwoWay}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate x:DataType="entities:AccountSignature"> <DataTemplate x:DataType="entities:AccountSignature">
<TextBlock Text="{x:Bind Name}" /> <TextBlock Text="{x:Bind Name}" />
@@ -91,7 +91,7 @@
IsActionIconVisible="False" IsActionIconVisible="False"
IsClickEnabled="False" IsClickEnabled="False"
IsEnabled="{x:Bind ViewModel.IsSignatureEnabled, Mode=OneWay}"> IsEnabled="{x:Bind ViewModel.IsSignatureEnabled, Mode=OneWay}">
<ComboBox ItemsSource="{x:Bind ViewModel.Signatures}" SelectedIndex="{x:Bind ViewModel.SignatureForFollowingMessagesIndex, Mode=TwoWay}"> <ComboBox ItemsSource="{x:Bind ViewModel.Signatures}" SelectedItem="{x:Bind ViewModel.SelectedSignatureForFollowingMessages, Mode=TwoWay}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate x:DataType="entities:AccountSignature"> <DataTemplate x:DataType="entities:AccountSignature">
<TextBlock Text="{x:Bind Name}" /> <TextBlock Text="{x:Bind Name}" />
+61 -7
View File
@@ -147,9 +147,30 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
public void Receive(SettingsRootNavigationRequested message) public void Receive(SettingsRootNavigationRequested message)
{ {
var currentRootPage = SettingsNavigationInfoProvider.GetRootPage(PageHistory.LastOrDefault()?.Request.PageType ?? WinoPage.SettingOptionsPage); var activePage = PageHistory.LastOrDefault()?.Request.PageType ?? WinoPage.SettingOptionsPage;
if (message.PageType != WinoPage.SettingOptionsPage && currentRootPage == message.PageType) var currentRootPage = SettingsNavigationInfoProvider.GetRootPage(activePage);
if (message.PageType == currentRootPage)
{
if (activePage == currentRootPage)
return;
var currentRootIndex = PageHistory
.Select((item, index) => new { item.Request.PageType, Index = index })
.FirstOrDefault(item => item.PageType == currentRootPage)?.Index ?? -1;
if (TryNavigateToBreadcrumbIndex(currentRootIndex))
return;
}
if (message.PageType == WinoPage.SettingOptionsPage)
{
if (activePage == WinoPage.SettingOptionsPage)
return;
NavigateToSettingsHome();
return; return;
}
NavigateToRootPage(message.PageType); NavigateToRootPage(message.PageType);
} }
@@ -196,11 +217,7 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
private void NavigateToRootPage(WinoPage targetPage) private void NavigateToRootPage(WinoPage targetPage)
{ {
PageHistory.Clear(); NavigateToSettingsHome();
SettingsFrame.BackStack.Clear();
SettingsFrame.ForwardStack.Clear();
NavigateBreadcrumb(new BreadcrumbNavigationRequested(Translator.MenuSettings, WinoPage.SettingOptionsPage));
if (targetPage != WinoPage.SettingOptionsPage) if (targetPage != WinoPage.SettingOptionsPage)
{ {
@@ -213,6 +230,43 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
UpdateWindowTitle(); UpdateWindowTitle();
} }
private void NavigateToSettingsHome()
{
if (PageHistory.Count == 0 || SettingsFrame.Content == null)
{
ResetToSettingsHome();
return;
}
if (PageHistory.Count == 1)
return;
if (!TryNavigateToBreadcrumbIndex(0))
{
ResetToSettingsHome();
}
}
private bool TryNavigateToBreadcrumbIndex(int targetIndex)
{
if (!BreadcrumbNavigationHelper.NavigateTo(SettingsFrame, PageHistory, targetIndex))
return false;
UpdateBackNavigationState();
_ = RefreshCurrentPageStateAsync();
UpdateWindowTitle();
return true;
}
private void ResetToSettingsHome()
{
PageHistory.Clear();
SettingsFrame.BackStack.Clear();
SettingsFrame.ForwardStack.Clear();
NavigateBreadcrumb(new BreadcrumbNavigationRequested(Translator.MenuSettings, WinoPage.SettingOptionsPage));
}
public void ResetForModeSwitch() public void ResetForModeSwitch()
{ {
while (PageHistory.Count > 1 && SettingsFrame.CanGoBack) while (PageHistory.Count > 1 && SettingsFrame.CanGoBack)
+334 -32
View File
@@ -727,32 +727,70 @@ public class MailService : BaseDatabaseService, IMailService
public async Task DeleteMailAsync(Guid accountId, string mailCopyId) public async Task DeleteMailAsync(Guid accountId, string mailCopyId)
{ {
var allMails = await GetMailCopiesByIdAsync([mailCopyId]).ConfigureAwait(false); await DeleteMailsAsync(accountId, [mailCopyId]).ConfigureAwait(false);
}
foreach (var mailItem in allMails) public async Task DeleteMailsAsync(Guid accountId, IEnumerable<string> mailCopyIds)
{ {
// Delete mime file as well. var targetMailIds = mailCopyIds?
// Even though Gmail might have multiple copies for the same mail, we only have one MIME file for all. .Where(id => !string.IsNullOrWhiteSpace(id))
// Their FileId is inserted same. .Distinct(StringComparer.Ordinal)
.ToList() ?? [];
await DeleteMailInternalAsync(mailItem, preserveMimeFile: false).ConfigureAwait(false); if (targetMailIds.Count == 0)
} return;
var allMails = await GetMailCopiesByIdAsync(targetMailIds).ConfigureAwait(false);
await DeleteMailCopiesAsync(allMails, preserveMimeFile: false, reportUiChange: true).ConfigureAwait(false);
}
private void ReportAddedMails(IReadOnlyList<MailCopy> addedMails)
{
if (addedMails == null || addedMails.Count == 0)
return;
if (addedMails.Count == 1)
ReportUIChange(new MailAddedMessage(addedMails[0], EntityUpdateSource.Server));
else
ReportUIChange(new BulkMailAddedMessage(addedMails, EntityUpdateSource.Server));
}
private void ReportUpdatedMails(IReadOnlyList<MailCopy> updatedMails, MailCopyChangeFlags changedProperties = MailCopyChangeFlags.None)
{
if (updatedMails == null || updatedMails.Count == 0)
return;
if (updatedMails.Count == 1)
ReportUIChange(new MailUpdatedMessage(updatedMails[0], EntityUpdateSource.Server, changedProperties));
else
ReportUIChange(new BulkMailUpdatedMessage(updatedMails, EntityUpdateSource.Server, changedProperties));
}
private void ReportRemovedMails(IReadOnlyList<MailCopy> removedMails)
{
if (removedMails == null || removedMails.Count == 0)
return;
if (removedMails.Count == 1)
ReportUIChange(new MailRemovedMessage(removedMails[0], EntityUpdateSource.Server));
else
ReportUIChange(new BulkMailRemovedMessage(removedMails, EntityUpdateSource.Server));
} }
#region Repository Calls #region Repository Calls
private async Task InsertMailAsync(MailCopy mailCopy) private async Task<MailCopy> InsertMailAsync(MailCopy mailCopy, bool reportUiChange)
{ {
if (mailCopy == null) if (mailCopy == null)
{ {
_logger.Warning("Null mail passed to InsertMailAsync call."); _logger.Warning("Null mail passed to InsertMailAsync call.");
return; return null;
} }
if (mailCopy.FolderId == Guid.Empty) if (mailCopy.FolderId == Guid.Empty)
{ {
_logger.Warning("Invalid FolderId for MailCopyId {Id} for InsertMailAsync", mailCopy.Id); _logger.Warning("Invalid FolderId for MailCopyId {Id} for InsertMailAsync", mailCopy.Id);
return; return null;
} }
_logger.Debug("Inserting mail {MailCopyId} to {FolderName}", mailCopy.Id, mailCopy.AssignedFolder.FolderName); _logger.Debug("Inserting mail {MailCopyId} to {FolderName}", mailCopy.Id, mailCopy.AssignedFolder.FolderName);
@@ -760,21 +798,27 @@ public class MailService : BaseDatabaseService, IMailService
await Connection.InsertAsync(mailCopy, typeof(MailCopy)).ConfigureAwait(false); await Connection.InsertAsync(mailCopy, typeof(MailCopy)).ConfigureAwait(false);
var hydratedMailCopy = await HydrateMailCopyAsync(mailCopy).ConfigureAwait(false); var hydratedMailCopy = await HydrateMailCopyAsync(mailCopy).ConfigureAwait(false);
ReportUIChange(new MailAddedMessage(hydratedMailCopy, EntityUpdateSource.Server)); if (reportUiChange)
ReportAddedMails([hydratedMailCopy]);
return hydratedMailCopy;
} }
public async Task UpdateMailAsync(MailCopy mailCopy) public async Task UpdateMailAsync(MailCopy mailCopy)
=> await UpdateMailAsync(mailCopy, reportUiChange: true).ConfigureAwait(false);
private async Task<MailCopy> UpdateMailAsync(MailCopy mailCopy, bool reportUiChange, MailCopy existingMailCopy = null)
{ {
if (mailCopy == null) if (mailCopy == null)
{ {
_logger.Warning("Null mail passed to UpdateMailAsync call."); _logger.Warning("Null mail passed to UpdateMailAsync call.");
return; return null;
} }
_logger.Debug("Updating mail {MailCopyId} with Folder {FolderId}", mailCopy.Id, mailCopy.FolderId); _logger.Debug("Updating mail {MailCopyId} with Folder {FolderId}", mailCopy.Id, mailCopy.FolderId);
var existingMailCopy = mailCopy.UniqueId != Guid.Empty existingMailCopy ??= mailCopy.UniqueId != Guid.Empty
? await Connection.FindAsync<MailCopy>(mailCopy.UniqueId).ConfigureAwait(false) ? await Connection.FindAsync<MailCopy>(mailCopy.UniqueId).ConfigureAwait(false)
: null; : null;
@@ -787,16 +831,19 @@ public class MailService : BaseDatabaseService, IMailService
await Connection.UpdateAsync(mailCopy, typeof(MailCopy)).ConfigureAwait(false); await Connection.UpdateAsync(mailCopy, typeof(MailCopy)).ConfigureAwait(false);
var hydratedMailCopy = await HydrateMailCopyAsync(mailCopy).ConfigureAwait(false); var hydratedMailCopy = await HydrateMailCopyAsync(mailCopy).ConfigureAwait(false);
ReportUIChange(new MailUpdatedMessage(hydratedMailCopy, EntityUpdateSource.Server)); if (reportUiChange)
ReportUpdatedMails([hydratedMailCopy]);
return hydratedMailCopy;
} }
private async Task DeleteMailInternalAsync(MailCopy mailCopy, bool preserveMimeFile) private async Task<MailCopy> DeleteMailInternalAsync(MailCopy mailCopy, bool preserveMimeFile, bool reportUiChange)
{ {
if (mailCopy == null) if (mailCopy == null)
{ {
_logger.Warning("Null mail passed to DeleteMailAsync call."); _logger.Warning("Null mail passed to DeleteMailAsync call.");
return; return null;
} }
_logger.Debug("Deleting mail {Id} from folder {FolderName}", mailCopy.Id, mailCopy.AssignedFolder.FolderName); _logger.Debug("Deleting mail {Id} from folder {FolderName}", mailCopy.Id, mailCopy.AssignedFolder.FolderName);
@@ -812,7 +859,31 @@ public class MailService : BaseDatabaseService, IMailService
await _mimeFileService.DeleteMimeMessageAsync(mailCopy.AssignedAccount.Id, mailCopy.FileId).ConfigureAwait(false); await _mimeFileService.DeleteMimeMessageAsync(mailCopy.AssignedAccount.Id, mailCopy.FileId).ConfigureAwait(false);
} }
ReportUIChange(new MailRemovedMessage(mailCopy, EntityUpdateSource.Server)); if (reportUiChange)
ReportRemovedMails([mailCopy]);
return mailCopy;
}
private async Task<List<MailCopy>> DeleteMailCopiesAsync(IReadOnlyList<MailCopy> mailCopies, bool preserveMimeFile, bool reportUiChange)
{
if (mailCopies == null || mailCopies.Count == 0)
return [];
var removedMails = new List<MailCopy>(mailCopies.Count);
foreach (var mailCopy in mailCopies)
{
var removedMail = await DeleteMailInternalAsync(mailCopy, preserveMimeFile, reportUiChange: false).ConfigureAwait(false);
if (removedMail != null)
removedMails.Add(removedMail);
}
if (reportUiChange)
ReportRemovedMails(removedMails);
return removedMails;
} }
#endregion #endregion
@@ -1021,6 +1092,40 @@ public class MailService : BaseDatabaseService, IMailService
} }
public async Task CreateAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId) public async Task CreateAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId)
=> await CreateAssignmentsAsync(accountId, [new MailFolderAssignmentUpdate(mailCopyId, remoteFolderId)]).ConfigureAwait(false);
public async Task CreateAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments)
{
var targetAssignments = assignments?
.Where(x => x != null &&
!string.IsNullOrWhiteSpace(x.MailCopyId) &&
!string.IsNullOrWhiteSpace(x.RemoteFolderId))
.GroupBy(x => $"{x.MailCopyId}\u001f{x.RemoteFolderId}", StringComparer.Ordinal)
.Select(group => group.First())
.ToList() ?? [];
if (targetAssignments.Count == 0)
return;
var addedMails = new List<MailCopy>(targetAssignments.Count);
var removedMails = new List<MailCopy>();
foreach (var assignment in targetAssignments)
{
var (addedMail, removedMail) = await CreateAssignmentInternalAsync(accountId, assignment.MailCopyId, assignment.RemoteFolderId).ConfigureAwait(false);
if (removedMail != null)
removedMails.Add(removedMail);
if (addedMail != null)
addedMails.Add(addedMail);
}
ReportRemovedMails(removedMails);
ReportAddedMails(addedMails);
}
private async Task<(MailCopy AddedMail, MailCopy RemovedMail)> CreateAssignmentInternalAsync(Guid accountId, string mailCopyId, string remoteFolderId)
{ {
// Note: Folder might not be available at the moment due to user not syncing folders before the delta processing. // Note: Folder might not be available at the moment due to user not syncing folders before the delta processing.
// This is a problem, because assignments won't be created. // This is a problem, because assignments won't be created.
@@ -1033,14 +1138,14 @@ public class MailService : BaseDatabaseService, IMailService
_logger.Warning("Local folder not found for remote folder {RemoteFolderId}", remoteFolderId); _logger.Warning("Local folder not found for remote folder {RemoteFolderId}", remoteFolderId);
_logger.Warning("Skipping assignment creation for the the message {MailCopyId}", mailCopyId); _logger.Warning("Skipping assignment creation for the the message {MailCopyId}", mailCopyId);
return; return (null, null);
} }
if (await IsMailExistsAsync(mailCopyId, localFolder.Id).ConfigureAwait(false)) if (await IsMailExistsAsync(mailCopyId, localFolder.Id).ConfigureAwait(false))
{ {
_logger.Debug("Skipping assignment creation for {MailCopyId} because folder {FolderId} already has a local copy.", _logger.Debug("Skipping assignment creation for {MailCopyId} because folder {FolderId} already has a local copy.",
mailCopyId, localFolder.Id); mailCopyId, localFolder.Id);
return; return (null, null);
} }
var mailCopy = await GetSingleMailItemWithoutFolderAssignmentAsync(mailCopyId); var mailCopy = await GetSingleMailItemWithoutFolderAssignmentAsync(mailCopyId);
@@ -1049,9 +1154,12 @@ public class MailService : BaseDatabaseService, IMailService
{ {
_logger.Warning("Can't create assignment for mail {MailCopyId} because it does not exist.", mailCopyId); _logger.Warning("Can't create assignment for mail {MailCopyId} because it does not exist.", mailCopyId);
return; return (null, null);
} }
MailCopy removedMail = null;
var mailCopyToInsert = mailCopy;
if (mailCopy.AssignedFolder.SpecialFolderType == SpecialFolderType.Sent && if (mailCopy.AssignedFolder.SpecialFolderType == SpecialFolderType.Sent &&
localFolder.SpecialFolderType == SpecialFolderType.Deleted) localFolder.SpecialFolderType == SpecialFolderType.Deleted)
{ {
@@ -1062,21 +1170,52 @@ public class MailService : BaseDatabaseService, IMailService
// This way item will only be visible in Trash folder as in Gmail Web UI. // This way item will only be visible in Trash folder as in Gmail Web UI.
// Don't delete MIME file since if exists. // Don't delete MIME file since if exists.
await DeleteMailInternalAsync(mailCopy, preserveMimeFile: true).ConfigureAwait(false); mailCopyToInsert = CloneMailCopy(mailCopy);
removedMail = await DeleteMailInternalAsync(mailCopy, preserveMimeFile: true, reportUiChange: false).ConfigureAwait(false);
} }
// Copy one of the mail copy and assign it to the new folder. // Copy one of the mail copy and assign it to the new folder.
// We don't need to create a new MIME pack. // We don't need to create a new MIME pack.
// Therefore FileId is not changed for the new MailCopy. // Therefore FileId is not changed for the new MailCopy.
mailCopy.UniqueId = Guid.NewGuid(); mailCopyToInsert.UniqueId = Guid.NewGuid();
mailCopy.FolderId = localFolder.Id; mailCopyToInsert.FolderId = localFolder.Id;
mailCopy.AssignedFolder = localFolder; mailCopyToInsert.AssignedFolder = localFolder;
await InsertMailAsync(mailCopy).ConfigureAwait(false); var addedMail = await InsertMailAsync(mailCopyToInsert, reportUiChange: false).ConfigureAwait(false);
return (addedMail, removedMail);
} }
public async Task DeleteAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId) public async Task DeleteAssignmentAsync(Guid accountId, string mailCopyId, string remoteFolderId)
=> await DeleteAssignmentsAsync(accountId, [new MailFolderAssignmentUpdate(mailCopyId, remoteFolderId)]).ConfigureAwait(false);
public async Task DeleteAssignmentsAsync(Guid accountId, IEnumerable<MailFolderAssignmentUpdate> assignments)
{
var targetAssignments = assignments?
.Where(x => x != null &&
!string.IsNullOrWhiteSpace(x.MailCopyId) &&
!string.IsNullOrWhiteSpace(x.RemoteFolderId))
.GroupBy(x => $"{x.MailCopyId}\u001f{x.RemoteFolderId}", StringComparer.Ordinal)
.Select(group => group.First())
.ToList() ?? [];
if (targetAssignments.Count == 0)
return;
var removedMails = new List<MailCopy>(targetAssignments.Count);
foreach (var assignment in targetAssignments)
{
var removedMail = await DeleteAssignmentInternalAsync(accountId, assignment.MailCopyId, assignment.RemoteFolderId).ConfigureAwait(false);
if (removedMail != null)
removedMails.Add(removedMail);
}
ReportRemovedMails(removedMails);
}
private async Task<MailCopy> DeleteAssignmentInternalAsync(Guid accountId, string mailCopyId, string remoteFolderId)
{ {
var mailItem = await GetSingleMailItemAsync(mailCopyId, remoteFolderId).ConfigureAwait(false); var mailItem = await GetSingleMailItemAsync(mailCopyId, remoteFolderId).ConfigureAwait(false);
@@ -1084,7 +1223,7 @@ public class MailService : BaseDatabaseService, IMailService
{ {
_logger.Warning("Mail not found with id {MailCopyId} with remote folder {RemoteFolderId}", mailCopyId, remoteFolderId); _logger.Warning("Mail not found with id {MailCopyId} with remote folder {RemoteFolderId}", mailCopyId, remoteFolderId);
return; return null;
} }
var localFolder = await _folderService.GetFolderAsync(accountId, remoteFolderId); var localFolder = await _folderService.GetFolderAsync(accountId, remoteFolderId);
@@ -1093,10 +1232,50 @@ public class MailService : BaseDatabaseService, IMailService
{ {
_logger.Warning("Local folder not found for remote folder {RemoteFolderId}", remoteFolderId); _logger.Warning("Local folder not found for remote folder {RemoteFolderId}", remoteFolderId);
return; return null;
} }
await DeleteMailInternalAsync(mailItem, preserveMimeFile: false).ConfigureAwait(false); return await DeleteMailInternalAsync(mailItem, preserveMimeFile: false, reportUiChange: false).ConfigureAwait(false);
}
private static MailCopy CloneMailCopy(MailCopy source)
{
if (source == null)
return null;
return new MailCopy
{
UniqueId = source.UniqueId,
Id = source.Id,
FolderId = source.FolderId,
ThreadId = source.ThreadId,
MessageId = source.MessageId,
References = source.References,
InReplyTo = source.InReplyTo,
FromName = source.FromName,
FromAddress = source.FromAddress,
Subject = source.Subject,
PreviewText = source.PreviewText,
CreationDate = source.CreationDate,
Importance = source.Importance,
IsRead = source.IsRead,
IsFlagged = source.IsFlagged,
IsPinned = source.IsPinned,
IsFocused = source.IsFocused,
HasAttachments = source.HasAttachments,
ItemType = source.ItemType,
DraftId = source.DraftId,
IsDraft = source.IsDraft,
FileId = source.FileId,
AssignedFolder = source.AssignedFolder,
AssignedAccount = source.AssignedAccount,
SenderContact = source.SenderContact,
IsReadReceiptRequested = source.IsReadReceiptRequested,
ReadReceiptStatus = source.ReadReceiptStatus,
ReadReceiptAcknowledgedAtUtc = source.ReadReceiptAcknowledgedAtUtc,
ReadReceiptMessageUniqueId = source.ReadReceiptMessageUniqueId,
Categories = source.Categories == null ? [] : [.. source.Categories]
};
} }
public async Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package) public async Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package)
@@ -1113,7 +1292,7 @@ public class MailService : BaseDatabaseService, IMailService
await SaveContactsForPackageAsync(package).ConfigureAwait(false); await SaveContactsForPackageAsync(package).ConfigureAwait(false);
var mimeSaveTask = _mimeFileService.SaveMimeMessageAsync(mailCopy.FileId, mimeMessage, account.Id); var mimeSaveTask = _mimeFileService.SaveMimeMessageAsync(mailCopy.FileId, mimeMessage, account.Id);
var insertMailTask = InsertMailAsync(mailCopy); var insertMailTask = InsertMailAsync(mailCopy, reportUiChange: true);
await Task.WhenAll(mimeSaveTask, insertMailTask).ConfigureAwait(false); await Task.WhenAll(mimeSaveTask, insertMailTask).ConfigureAwait(false);
await _sentMailReceiptService.TrackSentMailAsync(mailCopy, mimeMessage).ConfigureAwait(false); await _sentMailReceiptService.TrackSentMailAsync(mailCopy, mimeMessage).ConfigureAwait(false);
@@ -1125,6 +1304,129 @@ public class MailService : BaseDatabaseService, IMailService
} }
public async Task CreateMailsAsync(Guid accountId, IReadOnlyList<NewMailItemPackage> packages)
{
var targetPackages = packages?
.Where(package => package != null)
.ToList() ?? [];
if (targetPackages.Count == 0)
return;
var account = await _accountService.GetAccountAsync(accountId).ConfigureAwait(false);
if (account == null)
return;
if (account.ProviderType != MailProviderType.Gmail)
{
foreach (var package in targetPackages)
await CreateMailAsync(accountId, package).ConfigureAwait(false);
return;
}
var pendingInserts = new List<(MailCopy MailCopy, NewMailItemPackage Package, MimeMessage MimeMessage)>();
var pendingUpdates = new List<(MailCopy MailCopy, MailCopy ExistingMailCopy, NewMailItemPackage Package, MimeMessage MimeMessage)>();
foreach (var package in targetPackages)
{
if (string.IsNullOrEmpty(package.AssignedRemoteFolderId))
{
_logger.Warning("Remote folder id is not set for {MailCopyId}.", package.Copy?.Id);
_logger.Warning("Ignoring creation of mail.");
continue;
}
var assignedFolder = await _folderService.GetFolderAsync(accountId, package.AssignedRemoteFolderId).ConfigureAwait(false);
if (assignedFolder == null)
{
_logger.Warning("Assigned folder not found for {MailCopyId}.", package.Copy?.Id);
_logger.Warning("Ignoring creation of mail.");
continue;
}
var mailCopy = package.Copy;
var mimeMessage = package.Mime;
mailCopy.UniqueId = Guid.NewGuid();
mailCopy.AssignedAccount = account;
mailCopy.AssignedFolder = assignedFolder;
mailCopy.SenderContact = await GetSenderContactForAccountAsync(account, mailCopy.FromAddress).ConfigureAwait(false);
mailCopy.FolderId = assignedFolder.Id;
if (mimeMessage != null)
{
var isMimeExists = await _mimeFileService.IsMimeExistAsync(accountId, mailCopy.FileId).ConfigureAwait(false);
if (!isMimeExists)
{
bool isMimeSaved = await _mimeFileService.SaveMimeMessageAsync(mailCopy.FileId, mimeMessage, accountId).ConfigureAwait(false);
if (!isMimeSaved)
{
_logger.Warning("Failed to save mime file for {MailCopyId}.", mailCopy.Id);
}
}
}
await SaveContactsForPackageAsync(package).ConfigureAwait(false);
var existingCopyItem = await Connection.Table<MailCopy>()
.FirstOrDefaultAsync(a => a.Id == mailCopy.Id && a.FolderId == assignedFolder.Id)
.ConfigureAwait(false);
if (existingCopyItem != null)
{
mailCopy.UniqueId = existingCopyItem.UniqueId;
pendingUpdates.Add((mailCopy, existingCopyItem, package, mimeMessage));
}
else
{
pendingInserts.Add((mailCopy, package, mimeMessage));
}
}
var insertedMails = new List<MailCopy>(pendingInserts.Count);
foreach (var pendingInsert in pendingInserts)
{
var insertedMail = await InsertMailAsync(pendingInsert.MailCopy, reportUiChange: false).ConfigureAwait(false);
if (insertedMail != null)
insertedMails.Add(insertedMail);
}
var updatedMails = new List<MailCopy>(pendingUpdates.Count);
foreach (var pendingUpdate in pendingUpdates)
{
var updatedMail = await UpdateMailAsync(
pendingUpdate.MailCopy,
reportUiChange: false,
existingMailCopy: pendingUpdate.ExistingMailCopy).ConfigureAwait(false);
if (updatedMail != null)
updatedMails.Add(updatedMail);
}
ReportAddedMails(insertedMails);
ReportUpdatedMails(updatedMails);
foreach (var pendingInsert in pendingInserts)
{
await ReplaceMailCategoriesForPackageAsync(accountId, pendingInsert.MailCopy, pendingInsert.Package).ConfigureAwait(false);
await _sentMailReceiptService.TrackSentMailAsync(pendingInsert.MailCopy, pendingInsert.MimeMessage).ConfigureAwait(false);
await _sentMailReceiptService.ProcessIncomingReceiptAsync(pendingInsert.MailCopy, pendingInsert.MimeMessage).ConfigureAwait(false);
}
foreach (var pendingUpdate in pendingUpdates)
{
await ReplaceMailCategoriesForPackageAsync(accountId, pendingUpdate.MailCopy, pendingUpdate.Package).ConfigureAwait(false);
await _sentMailReceiptService.TrackSentMailAsync(pendingUpdate.MailCopy, pendingUpdate.MimeMessage).ConfigureAwait(false);
await _sentMailReceiptService.ProcessIncomingReceiptAsync(pendingUpdate.MailCopy, pendingUpdate.MimeMessage).ConfigureAwait(false);
}
}
public async Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package) public async Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package)
{ {
var account = await _accountService.GetAccountAsync(accountId).ConfigureAwait(false); var account = await _accountService.GetAccountAsync(accountId).ConfigureAwait(false);
@@ -1193,7 +1495,7 @@ public class MailService : BaseDatabaseService, IMailService
{ {
mailCopy.UniqueId = existingCopyItem.UniqueId; mailCopy.UniqueId = existingCopyItem.UniqueId;
await UpdateMailAsync(mailCopy).ConfigureAwait(false); await UpdateMailAsync(mailCopy, reportUiChange: true, existingMailCopy: existingCopyItem).ConfigureAwait(false);
await ReplaceMailCategoriesForPackageAsync(accountId, mailCopy, package).ConfigureAwait(false); await ReplaceMailCategoriesForPackageAsync(accountId, mailCopy, package).ConfigureAwait(false);
await _sentMailReceiptService.TrackSentMailAsync(mailCopy, mimeMessage).ConfigureAwait(false); await _sentMailReceiptService.TrackSentMailAsync(mailCopy, mimeMessage).ConfigureAwait(false);
await _sentMailReceiptService.ProcessIncomingReceiptAsync(mailCopy, mimeMessage).ConfigureAwait(false); await _sentMailReceiptService.ProcessIncomingReceiptAsync(mailCopy, mimeMessage).ConfigureAwait(false);
@@ -1210,7 +1512,7 @@ public class MailService : BaseDatabaseService, IMailService
await DeleteMailAsync(accountId, mailCopy.Id).ConfigureAwait(false); await DeleteMailAsync(accountId, mailCopy.Id).ConfigureAwait(false);
} }
await InsertMailAsync(mailCopy).ConfigureAwait(false); await InsertMailAsync(mailCopy, reportUiChange: true).ConfigureAwait(false);
await ReplaceMailCategoriesForPackageAsync(accountId, mailCopy, package).ConfigureAwait(false); await ReplaceMailCategoriesForPackageAsync(accountId, mailCopy, package).ConfigureAwait(false);
await _sentMailReceiptService.TrackSentMailAsync(mailCopy, mimeMessage).ConfigureAwait(false); await _sentMailReceiptService.TrackSentMailAsync(mailCopy, mimeMessage).ConfigureAwait(false);
await _sentMailReceiptService.ProcessIncomingReceiptAsync(mailCopy, mimeMessage).ConfigureAwait(false); await _sentMailReceiptService.ProcessIncomingReceiptAsync(mailCopy, mimeMessage).ConfigureAwait(false);
+3
View File
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Wino.Core.Tests")]
+68 -3
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
@@ -19,17 +20,19 @@ public class TranslationService : ITranslationService
private ILogger _logger = Log.ForContext<TranslationService>(); private ILogger _logger = Log.ForContext<TranslationService>();
private readonly IPreferencesService _preferencesService; private readonly IPreferencesService _preferencesService;
private readonly IConfigurationService _configurationService;
private bool isInitialized = false; private bool isInitialized = false;
public AppLanguageModel CurrentLanguageModel { get; private set; } public AppLanguageModel CurrentLanguageModel { get; private set; }
public TranslationService(IPreferencesService preferencesService) public TranslationService(IPreferencesService preferencesService, IConfigurationService configurationService)
{ {
_preferencesService = preferencesService; _preferencesService = preferencesService;
_configurationService = configurationService;
} }
// Initialize default language with ignoring current language check. // Initialize default language with ignoring current language check.
public Task InitializeAsync() => InitializeLanguageAsync(_preferencesService.CurrentLanguage, ignoreCurrentLanguageCheck: true); public Task InitializeAsync() => InitializeLanguageAsync(GetInitialLanguage(), ignoreCurrentLanguageCheck: true);
public async Task InitializeLanguageAsync(AppLanguage language, bool ignoreCurrentLanguageCheck = false) public async Task InitializeLanguageAsync(AppLanguage language, bool ignoreCurrentLanguageCheck = false)
{ {
@@ -65,6 +68,67 @@ public class TranslationService : ITranslationService
WeakReferenceMessenger.Default.Send(new LanguageChanged()); WeakReferenceMessenger.Default.Send(new LanguageChanged());
} }
private AppLanguage GetInitialLanguage()
{
if (_configurationService.Contains(nameof(IPreferencesService.CurrentLanguage)))
return _preferencesService.CurrentLanguage;
var windowsDisplayLanguage = CultureInfo.CurrentUICulture?.Name;
var initialLanguage = ResolveSupportedLanguage(
[
windowsDisplayLanguage ?? string.Empty,
CultureInfo.CurrentUICulture?.TwoLetterISOLanguageName ?? string.Empty
]);
_logger.Information("No saved app language preference found. Using Windows display language {LanguageTag} -> {Language}.",
string.IsNullOrWhiteSpace(windowsDisplayLanguage) ? "<unknown>" : windowsDisplayLanguage,
initialLanguage);
return initialLanguage;
}
internal static AppLanguage ResolveSupportedLanguage(IEnumerable<string> languageTags)
{
foreach (var languageTag in languageTags)
{
if (string.IsNullOrWhiteSpace(languageTag))
continue;
var normalizedLanguageTag = languageTag.Replace('_', '-').Trim();
var languageCode = normalizedLanguageTag.Split('-')[0];
if (TryResolveSupportedLanguage(languageCode, out var supportedLanguage))
return supportedLanguage;
}
return DefaultAppLanguage;
}
private static bool TryResolveSupportedLanguage(string languageCode, out AppLanguage supportedLanguage)
{
supportedLanguage = languageCode.ToLowerInvariant() switch
{
"cs" => AppLanguage.Czech,
"de" => AppLanguage.Deutsch,
"el" => AppLanguage.Greek,
"en" => AppLanguage.English,
"es" => AppLanguage.Spanish,
"fr" => AppLanguage.French,
"id" => AppLanguage.Indonesian,
"it" => AppLanguage.Italian,
"ko" => AppLanguage.Korean,
"pl" => AppLanguage.Polish,
"pt" => AppLanguage.PortugeseBrazil,
"ro" => AppLanguage.Romanian,
"ru" => AppLanguage.Russian,
"tr" => AppLanguage.Turkish,
"zh" => AppLanguage.Chinese,
_ => AppLanguage.None
};
return supportedLanguage != AppLanguage.None;
}
public List<AppLanguageModel> GetAvailableLanguages() public List<AppLanguageModel> GetAvailableLanguages()
{ {
return return
@@ -79,6 +143,7 @@ public class TranslationService : ITranslationService
new AppLanguageModel(AppLanguage.Indonesian, "Indonesian", "id-ID"), new AppLanguageModel(AppLanguage.Indonesian, "Indonesian", "id-ID"),
new AppLanguageModel(AppLanguage.Polish, "Polski", "pl-PL"), new AppLanguageModel(AppLanguage.Polish, "Polski", "pl-PL"),
new AppLanguageModel(AppLanguage.PortugeseBrazil, "Portuguese-Brazil", "pt-BR"), new AppLanguageModel(AppLanguage.PortugeseBrazil, "Portuguese-Brazil", "pt-BR"),
new AppLanguageModel(AppLanguage.Korean, "Korean", "ko-KR"),
new AppLanguageModel(AppLanguage.Russian, "Russian", "ru-RU"), new AppLanguageModel(AppLanguage.Russian, "Russian", "ru-RU"),
new AppLanguageModel(AppLanguage.Romanian, "Romanian", "ro-RO"), new AppLanguageModel(AppLanguage.Romanian, "Romanian", "ro-RO"),
new AppLanguageModel(AppLanguage.Spanish, "Spanish", "es-ES"), new AppLanguageModel(AppLanguage.Spanish, "Spanish", "es-ES"),
+1
View File
@@ -47,6 +47,7 @@ LOCALE_LABELS = {
"id_ID": "Indonesian (Indonesia)", "id_ID": "Indonesian (Indonesia)",
"it_IT": "Italian (Italy)", "it_IT": "Italian (Italy)",
"ja_JP": "Japanese (Japan)", "ja_JP": "Japanese (Japan)",
"ko_KR": "Korean (South Korea)",
"lt_LT": "Lithuanian (Lithuania)", "lt_LT": "Lithuanian (Lithuania)",
"nl_NL": "Dutch (Netherlands)", "nl_NL": "Dutch (Netherlands)",
"pl_PL": "Polish (Poland)", "pl_PL": "Polish (Poland)",