added notification system for file downloads and pair requests
This commit is contained in:
@@ -6,6 +6,7 @@ using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.API.Dto.User;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.Utils;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -104,7 +105,6 @@ public partial class ApiController
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Client_ReceiveBroadcastPairRequest(UserPairNotificationDto dto)
|
||||
{
|
||||
if (dto == null)
|
||||
@@ -112,17 +112,55 @@ public partial class ApiController
|
||||
|
||||
var request = _pairRequestService.RegisterIncomingRequest(dto.myHashedCid, dto.message ?? string.Empty);
|
||||
|
||||
Mediator.Publish(new NotificationMessage(
|
||||
"Pair request received",
|
||||
request.Message,
|
||||
NotificationType.Info,
|
||||
TimeSpan.FromSeconds(5)));
|
||||
// Use the new interactive notification system for pair requests
|
||||
var senderName = string.IsNullOrEmpty(request.DisplayName) ? "Unknown User" : request.DisplayName;
|
||||
_lightlessNotificationService.ShowPairRequestNotification(
|
||||
senderName,
|
||||
request.HashedCid,
|
||||
onAccept: () =>
|
||||
{
|
||||
// Fire and forget async operation
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var myCidHash = (await _dalamudUtil.GetCIDAsync().ConfigureAwait(false)).ToString().GetHash256();
|
||||
await TryPairWithContentId(request.HashedCid, myCidHash).ConfigureAwait(false);
|
||||
_pairRequestService.RemoveRequest(request.HashedCid);
|
||||
|
||||
_lightlessNotificationService.ShowNotification(
|
||||
"Pair Request Accepted",
|
||||
$"Sent a pair request back to {senderName}.",
|
||||
NotificationType.Info,
|
||||
TimeSpan.FromSeconds(3));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_lightlessNotificationService.ShowNotification(
|
||||
"Failed to Accept Pair Request",
|
||||
ex.Message,
|
||||
NotificationType.Error,
|
||||
TimeSpan.FromSeconds(5));
|
||||
}
|
||||
});
|
||||
},
|
||||
onDecline: () =>
|
||||
{
|
||||
_pairRequestService.RemoveRequest(request.HashedCid);
|
||||
_lightlessNotificationService.ShowNotification(
|
||||
"Pair Request Declined",
|
||||
$"Declined {senderName}'s pair request.",
|
||||
NotificationType.Info,
|
||||
TimeSpan.FromSeconds(3));
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Client_UpdateSystemInfo(SystemInfoDto systemInfo)
|
||||
{
|
||||
SystemInfoDto = systemInfo;
|
||||
//Mediator.Publish(new UpdateSystemInfoMessage(systemInfo));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user