From 0e9fd4373e4340cfd5a8a3333bc4e510dd058de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Tue, 11 Jun 2024 14:19:08 +0200 Subject: [PATCH] Create SendDraftRequest implementation and handle missing SentFolder synchronization. --- Wino.Core/Requests/SendDraftRequest.cs | 22 ++++++++++++++++++-- Wino.Mail.ViewModels/ComposePageViewModel.cs | 10 +-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Wino.Core/Requests/SendDraftRequest.cs b/Wino.Core/Requests/SendDraftRequest.cs index 4f3ce10e..5d5758e5 100644 --- a/Wino.Core/Requests/SendDraftRequest.cs +++ b/Wino.Core/Requests/SendDraftRequest.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; using CommunityToolkit.Mvvm.Messaging; using MoreLinq; @@ -9,8 +10,25 @@ using Wino.Core.Domain.Models.Requests; namespace Wino.Core.Requests { - public record SendDraftRequest(SendDraftPreparationRequest Request) : RequestBase(Request.MailItem, MailSynchronizerOperation.Send) + public record SendDraftRequest(SendDraftPreparationRequest Request) + : RequestBase(Request.MailItem, MailSynchronizerOperation.Send), + ICustomFolderSynchronizationRequest { + public List SynchronizationFolderIds + { + get + { + var folderIds = new List { Request.DraftFolder.Id }; + + if (Request.SentFolder != null) + { + folderIds.Add(Request.SentFolder.Id); + } + + return folderIds; + } + } + public override IBatchChangeRequest CreateBatch(IEnumerable matchingItems) => new BatchSendDraftRequestRequest(matchingItems, Request); diff --git a/Wino.Mail.ViewModels/ComposePageViewModel.cs b/Wino.Mail.ViewModels/ComposePageViewModel.cs index 3d7c03b4..0cbc30e8 100644 --- a/Wino.Mail.ViewModels/ComposePageViewModel.cs +++ b/Wino.Mail.ViewModels/ComposePageViewModel.cs @@ -160,15 +160,7 @@ namespace Wino.Mail.ViewModels isUpdatingMimeBlocked = true; var assignedAccount = CurrentMailDraftItem.AssignedAccount; - - MailItemFolder sentFolder = null; - - // Load the Sent folder if user wanted to have a copy there. - if (assignedAccount.Preferences.ShouldAppendMessagesToSentFolder) - { - sentFolder = await _folderService.GetSpecialFolderByAccountIdAsync(assignedAccount.Id, SpecialFolderType.Sent); - } - + var sentFolder = await _folderService.GetSpecialFolderByAccountIdAsync(assignedAccount.Id, SpecialFolderType.Sent); var draftSendPreparationRequest = new SendDraftPreparationRequest(CurrentMailDraftItem.MailCopy, currentMimeMessage, CurrentMailDraftItem.AssignedFolder, sentFolder, CurrentMailDraftItem.AssignedAccount.Preferences); await _worker.ExecuteAsync(draftSendPreparationRequest);