2024-07-18 20:04:11 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-06-21 01:40:25 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2024-04-18 01:44:37 +02:00
|
|
|
|
using Wino.Core.Domain;
|
|
|
|
|
|
using Wino.Core.Domain.Enums;
|
|
|
|
|
|
using Wino.Core.Domain.Interfaces;
|
|
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
namespace Wino.Mail.ViewModels;
|
|
|
|
|
|
|
2025-06-21 01:40:25 +02:00
|
|
|
|
public partial class MessageListPageViewModel : MailBaseViewModel
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
public IPreferencesService PreferencesService { get; }
|
2025-06-21 01:40:25 +02:00
|
|
|
|
private readonly IThumbnailService _thumbnailService;
|
2024-04-18 01:44:37 +02:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
private int selectedMarkAsOptionIndex;
|
|
|
|
|
|
public int SelectedMarkAsOptionIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => selectedMarkAsOptionIndex;
|
|
|
|
|
|
set
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
if (SetProperty(ref selectedMarkAsOptionIndex, value))
|
2024-07-18 20:04:11 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
if (value >= 0)
|
2024-07-18 20:04:11 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
PreferencesService.MarkAsPreference = (MailMarkAsOption)Enum.GetValues<MailMarkAsOption>().GetValue(value);
|
2024-07-18 20:04:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-16 11:54:23 +01:00
|
|
|
|
}
|
2024-07-18 20:04:11 +02:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
private readonly List<MailOperation> availableHoverActions =
|
|
|
|
|
|
[
|
|
|
|
|
|
MailOperation.Archive,
|
|
|
|
|
|
MailOperation.SoftDelete,
|
|
|
|
|
|
MailOperation.SetFlag,
|
|
|
|
|
|
MailOperation.MarkAsRead,
|
|
|
|
|
|
MailOperation.MoveToJunk
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
public List<string> AvailableHoverActionsTranslations { get; set; } =
|
|
|
|
|
|
[
|
|
|
|
|
|
Translator.HoverActionOption_Archive,
|
|
|
|
|
|
Translator.HoverActionOption_Delete,
|
|
|
|
|
|
Translator.HoverActionOption_ToggleFlag,
|
|
|
|
|
|
Translator.HoverActionOption_ToggleRead,
|
|
|
|
|
|
Translator.HoverActionOption_MoveJunk
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
private int leftHoverActionIndex;
|
|
|
|
|
|
public int LeftHoverActionIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => leftHoverActionIndex;
|
|
|
|
|
|
set
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
if (SetProperty(ref leftHoverActionIndex, value))
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
PreferencesService.LeftHoverAction = availableHoverActions[value];
|
2024-04-18 01:44:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-16 11:54:23 +01:00
|
|
|
|
}
|
2024-04-18 01:44:37 +02:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
private int centerHoverActionIndex;
|
|
|
|
|
|
public int CenterHoverActionIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => centerHoverActionIndex;
|
|
|
|
|
|
set
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
if (SetProperty(ref centerHoverActionIndex, value))
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
PreferencesService.CenterHoverAction = availableHoverActions[value];
|
2024-04-18 01:44:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-16 11:54:23 +01:00
|
|
|
|
}
|
2024-04-18 01:44:37 +02:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
private int rightHoverActionIndex;
|
|
|
|
|
|
public int RightHoverActionIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => rightHoverActionIndex;
|
|
|
|
|
|
set
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
if (SetProperty(ref rightHoverActionIndex, value))
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
PreferencesService.RightHoverAction = availableHoverActions[value];
|
2024-04-18 01:44:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-16 11:54:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-04-18 01:44:37 +02:00
|
|
|
|
|
2025-06-21 01:40:25 +02:00
|
|
|
|
public MessageListPageViewModel(IPreferencesService preferencesService, IThumbnailService thumbnailService)
|
2025-02-16 11:54:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
PreferencesService = preferencesService;
|
2025-06-21 01:40:25 +02:00
|
|
|
|
_thumbnailService = thumbnailService;
|
2025-02-16 11:54:23 +01:00
|
|
|
|
leftHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.LeftHoverAction);
|
|
|
|
|
|
centerHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.CenterHoverAction);
|
|
|
|
|
|
rightHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.RightHoverAction);
|
|
|
|
|
|
SelectedMarkAsOptionIndex = Array.IndexOf(Enum.GetValues<MailMarkAsOption>(), PreferencesService.MarkAsPreference);
|
2024-04-18 01:44:37 +02:00
|
|
|
|
}
|
2025-06-21 01:40:25 +02:00
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
|
private async Task ClearAvatarsCacheAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
await _thumbnailService.ClearCache();
|
|
|
|
|
|
}
|
2024-04-18 01:44:37 +02:00
|
|
|
|
}
|