RSVP options.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Requests;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
|
||||
namespace Wino.Core.Requests.Calendar;
|
||||
|
||||
/// <summary>
|
||||
/// Request to accept a calendar event invitation on the server.
|
||||
/// The calendar item status should be updated locally before queuing this request.
|
||||
/// </summary>
|
||||
public record AcceptEventRequest(CalendarItem Item, string ResponseMessage = null) : CalendarRequestBase(Item)
|
||||
{
|
||||
private readonly CalendarItemStatus _previousStatus = Item.Status;
|
||||
|
||||
public override CalendarSynchronizerOperation Operation => CalendarSynchronizerOperation.AcceptEvent;
|
||||
|
||||
/// <summary>
|
||||
/// After successful acceptance, we need to resync to get updated status.
|
||||
/// </summary>
|
||||
public override int ResynchronizationDelay => 2000;
|
||||
|
||||
public override void ApplyUIChanges()
|
||||
{
|
||||
// Update the item status locally
|
||||
Item.Status = CalendarItemStatus.Accepted;
|
||||
|
||||
// Notify UI that the event status was updated
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemUpdated(Item));
|
||||
}
|
||||
|
||||
public override void RevertUIChanges()
|
||||
{
|
||||
// If acceptance fails, revert to the previous status
|
||||
Item.Status = _previousStatus;
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemUpdated(Item));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Requests;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
|
||||
namespace Wino.Core.Requests.Calendar;
|
||||
|
||||
/// <summary>
|
||||
/// Request to decline a calendar event invitation on the server.
|
||||
/// The calendar item status should be updated locally before queuing this request.
|
||||
/// </summary>
|
||||
public record DeclineEventRequest(CalendarItem Item, string ResponseMessage = null) : CalendarRequestBase(Item)
|
||||
{
|
||||
private readonly CalendarItemStatus _previousStatus = Item.Status;
|
||||
|
||||
public override CalendarSynchronizerOperation Operation => CalendarSynchronizerOperation.DeclineEvent;
|
||||
|
||||
/// <summary>
|
||||
/// After successful decline, we need to resync to get updated status.
|
||||
/// </summary>
|
||||
public override int ResynchronizationDelay => 2000;
|
||||
|
||||
public override void ApplyUIChanges()
|
||||
{
|
||||
// Update the item status locally
|
||||
Item.Status = CalendarItemStatus.Cancelled;
|
||||
|
||||
// Notify UI that the event status was updated
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemUpdated(Item));
|
||||
}
|
||||
|
||||
public override void RevertUIChanges()
|
||||
{
|
||||
// If decline fails, revert to the previous status
|
||||
Item.Status = _previousStatus;
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemUpdated(Item));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Requests;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
|
||||
namespace Wino.Core.Requests.Calendar;
|
||||
|
||||
/// <summary>
|
||||
/// Outlook-specific request to decline a calendar event invitation.
|
||||
/// In Outlook, declined events are removed from the calendar by the API after synchronization,
|
||||
/// so this request sends a delete notification to remove the event from the UI.
|
||||
/// </summary>
|
||||
public record OutlookDeclineEventRequest(CalendarItem Item, string ResponseMessage = null) : CalendarRequestBase(Item)
|
||||
{
|
||||
private readonly CalendarItemStatus _previousStatus = Item.Status;
|
||||
|
||||
public override CalendarSynchronizerOperation Operation => CalendarSynchronizerOperation.DeclineEvent;
|
||||
|
||||
/// <summary>
|
||||
/// After successful decline, we need to resync to confirm the event is removed.
|
||||
/// </summary>
|
||||
public override int ResynchronizationDelay => 2000;
|
||||
|
||||
public override void ApplyUIChanges()
|
||||
{
|
||||
// In Outlook, declined events are deleted from the calendar after sync
|
||||
// Send deleted message to remove from UI immediately
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemDeleted(Item));
|
||||
}
|
||||
|
||||
public override void RevertUIChanges()
|
||||
{
|
||||
// If decline fails, restore the previous status and re-add the event
|
||||
Item.Status = _previousStatus;
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemAdded(Item));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Requests;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
|
||||
namespace Wino.Core.Requests.Calendar;
|
||||
|
||||
/// <summary>
|
||||
/// Request to tentatively accept a calendar event invitation on the server.
|
||||
/// The calendar item status should be updated locally before queuing this request.
|
||||
/// </summary>
|
||||
public record TentativeEventRequest(CalendarItem Item, string ResponseMessage = null) : CalendarRequestBase(Item)
|
||||
{
|
||||
private readonly CalendarItemStatus _previousStatus = Item.Status;
|
||||
|
||||
public override CalendarSynchronizerOperation Operation => CalendarSynchronizerOperation.TentativeEvent;
|
||||
|
||||
/// <summary>
|
||||
/// After successful tentative acceptance, we need to resync to get updated status.
|
||||
/// </summary>
|
||||
public override int ResynchronizationDelay => 2000;
|
||||
|
||||
public override void ApplyUIChanges()
|
||||
{
|
||||
// Update the item status locally
|
||||
Item.Status = CalendarItemStatus.Tentative;
|
||||
|
||||
// Notify UI that the event status was updated
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemUpdated(Item));
|
||||
}
|
||||
|
||||
public override void RevertUIChanges()
|
||||
{
|
||||
// If tentative acceptance fails, revert to the previous status
|
||||
Item.Status = _previousStatus;
|
||||
WeakReferenceMessenger.Default.Send(new CalendarItemUpdated(Item));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user