Cleaning up the solution. Separating Shared.WinRT, Services and Synchronization. Removing synchronization from app. Reducing bundle size by 45mb.
This commit is contained in:
53
Wino.Services/Requests/CreateDraftRequest.cs
Normal file
53
Wino.Services/Requests/CreateDraftRequest.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using MoreLinq;
|
||||
using Wino.Domain.Enums;
|
||||
using Wino.Domain.Interfaces;
|
||||
using Wino.Domain.Models.MailItem;
|
||||
using Wino.Domain.Models.Requests;
|
||||
using Wino.Messaging.Server;
|
||||
|
||||
namespace Wino.Services.Requests
|
||||
{
|
||||
public record CreateDraftRequest(DraftPreperationRequest DraftPreperationRequest)
|
||||
: RequestBase<BatchCreateDraftRequest>(DraftPreperationRequest.CreatedLocalDraftCopy, MailSynchronizerOperation.CreateDraft),
|
||||
ICustomFolderSynchronizationRequest
|
||||
{
|
||||
public List<Guid> SynchronizationFolderIds =>
|
||||
[
|
||||
DraftPreperationRequest.CreatedLocalDraftCopy.AssignedFolder.Id
|
||||
];
|
||||
|
||||
public override IBatchChangeRequest CreateBatch(IEnumerable<IRequest> matchingItems)
|
||||
=> new BatchCreateDraftRequest(matchingItems, DraftPreperationRequest);
|
||||
|
||||
public override void ApplyUIChanges()
|
||||
{
|
||||
// No need for it since Draft folder is automatically navigated and draft item is added + selected.
|
||||
// We only need to revert changes in case of network fails to create the draft.
|
||||
}
|
||||
|
||||
public override void RevertUIChanges()
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new MailRemovedMessage(Item));
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public record class BatchCreateDraftRequest(IEnumerable<IRequest> Items, DraftPreperationRequest DraftPreperationRequest)
|
||||
: BatchRequestBase(Items, MailSynchronizerOperation.CreateDraft)
|
||||
{
|
||||
public override void ApplyUIChanges()
|
||||
{
|
||||
// No need for it since Draft folder is automatically navigated and draft item is added + selected.
|
||||
// We only need to revert changes in case of network fails to create the draft.
|
||||
}
|
||||
|
||||
public override void RevertUIChanges()
|
||||
{
|
||||
Items.ForEach(item => WeakReferenceMessenger.Default.Send(new MailRemovedMessage(item.Item)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user