Create SendDraftRequest implementation and handle missing SentFolder synchronization.

This commit is contained in:
Burak Kaan Köse
2024-06-11 14:19:08 +02:00
parent 69a10c754a
commit 0e9fd4373e
2 changed files with 21 additions and 11 deletions

View File

@@ -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<BatchMarkReadRequest>(Request.MailItem, MailSynchronizerOperation.Send)
public record SendDraftRequest(SendDraftPreparationRequest Request)
: RequestBase<BatchMarkReadRequest>(Request.MailItem, MailSynchronizerOperation.Send),
ICustomFolderSynchronizationRequest
{
public List<Guid> SynchronizationFolderIds
{
get
{
var folderIds = new List<Guid> { Request.DraftFolder.Id };
if (Request.SentFolder != null)
{
folderIds.Add(Request.SentFolder.Id);
}
return folderIds;
}
}
public override IBatchChangeRequest CreateBatch(IEnumerable<IRequest> matchingItems)
=> new BatchSendDraftRequestRequest(matchingItems, Request);

View File

@@ -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);