feat: Enhanced sender avatars with gravatar and favicons integration (#685)
* feat: Enhanced sender avatars with gravatar and favicons integration * chore: Remove unused known companies thumbnails * feat(thumbnail): add IThumbnailService and refactor usage - Introduced a new interface `IThumbnailService` for handling thumbnail-related functionalities. - Registered `IThumbnailService` with its implementation `ThumbnailService` in the service container. - Updated `NotificationBuilder` to use an instance of `IThumbnailService` instead of static methods. - Refactored `ThumbnailService` from a static class to a regular class with instance methods and variables. - Modified `ImagePreviewControl` to utilize the new `IThumbnailService` instance. - Completed integration of `IThumbnailService` in the application by registering it in `App.xaml.cs`. * style: Show favicons as squares - Changed `hintCrop` in `NotificationBuilder` to `None` for app logo display. - Added `FaviconSquircle`, `FaviconImage`, and `isFavicon` to `ImagePreviewControl` for favicon handling. - Updated `UpdateInformation` method to manage favicon visibility. - Introduced `GetBitmapImageAsync` for converting Base64 to Bitmap images. - Enhanced XAML to include `FaviconSquircle` for improved UI appearance. * refactor thumbnail service * Removed old code and added clear method * added prefetch function * Change key from host to email * Remove redundant code * Test event * Fixed an issue with the thumbnail updated event. * Fix cutted favicons * exclude some domain from favicons * add yandex.ru * fix buttons in settings * remove prefetch method * Added thumbnails propagation to mailRenderingPage * Revert MailItemViewModel to object * Remove redundant code * spaces * await load parameter added * fix spaces * fix case sensativity for mail list thumbnails * change duckdns to google * Some cleanup. --------- Co-authored-by: Aleh Khantsevich <aleh.khantsevich@gmail.com> Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
This commit is contained in:
committed by
GitHub
parent
a8cb332232
commit
256fd1cce2
@@ -18,7 +18,6 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
|
||||
[ObservableProperty]
|
||||
private List<string> _appTerminationBehavior;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
public partial List<string> SearchModes { get; set; }
|
||||
|
||||
|
||||
@@ -129,11 +129,11 @@ public class WinoMailCollection
|
||||
private async Task HandleExistingThreadAsync(ObservableGroup<object, IMailItem> group, ThreadMailItemViewModel threadViewModel, MailCopy addedItem)
|
||||
{
|
||||
var existingGroupKey = GetGroupingKey(threadViewModel);
|
||||
|
||||
|
||||
await ExecuteUIThread(() => { threadViewModel.AddMailItemViewModel(addedItem); });
|
||||
|
||||
var newGroupKey = GetGroupingKey(threadViewModel);
|
||||
|
||||
|
||||
if (!existingGroupKey.Equals(newGroupKey))
|
||||
{
|
||||
await MoveThreadToNewGroupAsync(group, threadViewModel, newGroupKey);
|
||||
@@ -294,6 +294,25 @@ public class WinoMailCollection
|
||||
return null;
|
||||
}
|
||||
|
||||
public void UpdateThumbnails(string address)
|
||||
{
|
||||
if (CoreDispatcher == null) return;
|
||||
|
||||
CoreDispatcher.ExecuteOnUIThread(() =>
|
||||
{
|
||||
foreach (var group in _mailItemSource)
|
||||
{
|
||||
foreach (var item in group)
|
||||
{
|
||||
if (item is MailItemViewModel mailItemViewModel && mailItemViewModel.MailCopy.FromAddress.Equals(address, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mailItemViewModel.ThumbnailUpdatedEvent = !mailItemViewModel.ThumbnailUpdatedEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fins the item container that updated mail copy belongs to and updates it.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
using Wino.Core.Domain;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
|
||||
namespace Wino.Mail.ViewModels.Data;
|
||||
|
||||
public class AccountContactViewModel : AccountContact
|
||||
public partial class AccountContactViewModel : ObservableObject
|
||||
{
|
||||
public string Address { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Base64ContactPicture { get; set; }
|
||||
public bool IsRootContact { get; set; }
|
||||
|
||||
public AccountContactViewModel(AccountContact contact)
|
||||
{
|
||||
Address = contact.Address;
|
||||
@@ -39,4 +46,7 @@ public class AccountContactViewModel : AccountContact
|
||||
/// Display name of the contact in a format: Name <Address>.
|
||||
/// </summary>
|
||||
public string DisplayName => Address == Name || string.IsNullOrWhiteSpace(Name) ? Address.ToLowerInvariant() : $"{Name} <{Address.ToLowerInvariant()}>";
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool ThumbnailUpdatedEvent { get; set; }
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Wino.Mail.ViewModels.Data;
|
||||
public partial class MailItemViewModel(MailCopy mailCopy) : ObservableObject, IMailItem
|
||||
{
|
||||
[ObservableProperty]
|
||||
private MailCopy mailCopy = mailCopy;
|
||||
public partial MailCopy MailCopy { get; set; } = mailCopy;
|
||||
|
||||
public Guid UniqueId => ((IMailItem)MailCopy).UniqueId;
|
||||
public string ThreadId => ((IMailItem)MailCopy).ThreadId;
|
||||
@@ -23,10 +23,13 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableObject, IM
|
||||
public string InReplyTo => ((IMailItem)MailCopy).InReplyTo;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isCustomFocused;
|
||||
public partial bool ThumbnailUpdatedEvent { get; set; } = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isSelected;
|
||||
public partial bool IsCustomFocused { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsSelected { get; set; }
|
||||
|
||||
public bool IsFlagged
|
||||
{
|
||||
|
||||
@@ -41,7 +41,8 @@ public partial class MailListPageViewModel : MailBaseViewModel,
|
||||
IRecipient<AccountSynchronizationCompleted>,
|
||||
IRecipient<NewMailSynchronizationRequested>,
|
||||
IRecipient<AccountSynchronizerStateChanged>,
|
||||
IRecipient<AccountCacheResetMessage>
|
||||
IRecipient<AccountCacheResetMessage>,
|
||||
IRecipient<ThumbnailAdded>
|
||||
{
|
||||
private bool isChangingFolder = false;
|
||||
|
||||
@@ -1140,4 +1141,6 @@ public partial class MailListPageViewModel : MailBaseViewModel,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(ThumbnailAdded message) => MailCollection.UpdateThumbnails(message.Email);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,14 @@ using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.ViewModels.Messages;
|
||||
using Wino.Messaging.Client.Mails;
|
||||
using Wino.Messaging.Server;
|
||||
using Wino.Messaging.UI;
|
||||
using IMailService = Wino.Core.Domain.Interfaces.IMailService;
|
||||
|
||||
namespace Wino.Mail.ViewModels;
|
||||
|
||||
public partial class MailRenderingPageViewModel : MailBaseViewModel,
|
||||
IRecipient<NewMailItemRenderingRequestedEvent>,
|
||||
IRecipient<ThumbnailAdded>,
|
||||
ITransferProgress // For listening IMAP message download progress.
|
||||
{
|
||||
private readonly IMailDialogService _dialogService;
|
||||
@@ -788,4 +790,27 @@ public partial class MailRenderingPageViewModel : MailBaseViewModel,
|
||||
Log.Error(ex, "Failed to render mail.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(ThumbnailAdded message)
|
||||
{
|
||||
UpdateThumbnails(ToItems, message.Email);
|
||||
UpdateThumbnails(CcItems, message.Email);
|
||||
UpdateThumbnails(BccItems, message.Email);
|
||||
}
|
||||
|
||||
private void UpdateThumbnails(ObservableCollection<AccountContactViewModel> items, string email)
|
||||
{
|
||||
if (Dispatcher == null || items.Count == 0) return;
|
||||
|
||||
Dispatcher.ExecuteOnUIThread(() =>
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.Address.Equals(email, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.ThumbnailUpdatedEvent = !item.ThumbnailUpdatedEvent;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Mail.ViewModels;
|
||||
|
||||
public class MessageListPageViewModel : MailBaseViewModel
|
||||
public partial class MessageListPageViewModel : MailBaseViewModel
|
||||
{
|
||||
public IPreferencesService PreferencesService { get; }
|
||||
private readonly IThumbnailService _thumbnailService;
|
||||
|
||||
private int selectedMarkAsOptionIndex;
|
||||
|
||||
public int SelectedMarkAsOptionIndex
|
||||
{
|
||||
get => selectedMarkAsOptionIndex;
|
||||
@@ -46,9 +48,7 @@ public class MessageListPageViewModel : MailBaseViewModel
|
||||
];
|
||||
|
||||
#region Properties
|
||||
|
||||
private int leftHoverActionIndex;
|
||||
|
||||
public int LeftHoverActionIndex
|
||||
{
|
||||
get => leftHoverActionIndex;
|
||||
@@ -61,9 +61,7 @@ public class MessageListPageViewModel : MailBaseViewModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int centerHoverActionIndex;
|
||||
|
||||
public int CenterHoverActionIndex
|
||||
{
|
||||
get => centerHoverActionIndex;
|
||||
@@ -77,7 +75,6 @@ public class MessageListPageViewModel : MailBaseViewModel
|
||||
}
|
||||
|
||||
private int rightHoverActionIndex;
|
||||
|
||||
public int RightHoverActionIndex
|
||||
{
|
||||
get => rightHoverActionIndex;
|
||||
@@ -89,18 +86,21 @@ public class MessageListPageViewModel : MailBaseViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public MessageListPageViewModel(IMailDialogService dialogService,
|
||||
IPreferencesService preferencesService)
|
||||
public MessageListPageViewModel(IPreferencesService preferencesService, IThumbnailService thumbnailService)
|
||||
{
|
||||
PreferencesService = preferencesService;
|
||||
|
||||
_thumbnailService = thumbnailService;
|
||||
leftHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.LeftHoverAction);
|
||||
centerHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.CenterHoverAction);
|
||||
rightHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.RightHoverAction);
|
||||
|
||||
SelectedMarkAsOptionIndex = Array.IndexOf(Enum.GetValues<MailMarkAsOption>(), PreferencesService.MarkAsPreference);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task ClearAvatarsCacheAsync()
|
||||
{
|
||||
await _thumbnailService.ClearCache();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user