From 64f046f914214776e15432dffadd60b72433f5c3 Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Tue, 19 Mar 2024 13:06:12 +0100 Subject: [PATCH] remove unncessary sha1 dictionary, use new notification management --- MareSynchronos/PlayerData/Pairs/PairManager.cs | 2 +- MareSynchronos/Services/Mediator/Messages.cs | 2 +- MareSynchronos/Services/NotificationService.cs | 11 ++++++----- .../Services/PluginWarningNotificationService.cs | 2 +- .../SignalR/ApiController.Functions.Callbacks.cs | 6 +++--- MareSynchronos/WebAPI/SignalR/ApiController.cs | 2 +- .../WebAPI/SignalR/Utils/ForeverRetryPolicy.cs | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/MareSynchronos/PlayerData/Pairs/PairManager.cs b/MareSynchronos/PlayerData/Pairs/PairManager.cs index 9b12470..5f717d8 100644 --- a/MareSynchronos/PlayerData/Pairs/PairManager.cs +++ b/MareSynchronos/PlayerData/Pairs/PairManager.cs @@ -129,7 +129,7 @@ public sealed class PairManager : DisposableMediatorSubscriberBase var msg = !string.IsNullOrEmpty(note) ? $"{note} ({pair.UserData.AliasOrUID}) is now online" : $"{pair.UserData.AliasOrUID} is now online"; - Mediator.Publish(new NotificationMessage("User online", msg, NotificationType.Info, 5000)); + Mediator.Publish(new NotificationMessage("User online", msg, NotificationType.Info, TimeSpan.FromSeconds(5))); } pair.CreateCachedPlayer(dto); diff --git a/MareSynchronos/Services/Mediator/Messages.cs b/MareSynchronos/Services/Mediator/Messages.cs index 8adf6b8..c1d2b2d 100644 --- a/MareSynchronos/Services/Mediator/Messages.cs +++ b/MareSynchronos/Services/Mediator/Messages.cs @@ -49,7 +49,7 @@ public record RemoveWatchedGameObjectHandler(GameObjectHandler Handler) : Messag public record HaltScanMessage(string Source) : MessageBase; public record ResumeScanMessage(string Source) : MessageBase; public record NotificationMessage - (string Title, string Message, NotificationType Type, uint TimeShownOnScreen = 3000) : MessageBase; + (string Title, string Message, NotificationType Type, TimeSpan? TimeShownOnScreen = null) : MessageBase; public record CreateCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase; public record ClearCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase; public record CharacterDataCreatedMessage(CharacterData CharacterData) : SameThreadMessage; diff --git a/MareSynchronos/Services/NotificationService.cs b/MareSynchronos/Services/NotificationService.cs index abc4060..e2d9c9b 100644 --- a/MareSynchronos/Services/NotificationService.cs +++ b/MareSynchronos/Services/NotificationService.cs @@ -108,12 +108,13 @@ public class NotificationService : DisposableMediatorSubscriberBase private void ShowToast(NotificationMessage msg) { - var notification = new Notification{ + _notificationManager.AddNotification(new Dalamud.Interface.ImGuiNotification.Notification() + { Content = msg.Message ?? string.Empty, - Title = "[LoporritSync] " + msg.Title, + Title = msg.Title, Type = msg.Type, - InitialDuration = TimeSpan.FromMilliseconds(msg.TimeShownOnScreen) - }; - _notificationManager.AddNotification(notification); + Minimized = false, + InitialDuration = msg.TimeShownOnScreen ?? TimeSpan.FromSeconds(3) + }); } } \ No newline at end of file diff --git a/MareSynchronos/Services/PluginWarningNotificationService.cs b/MareSynchronos/Services/PluginWarningNotificationService.cs index b30a575..2193b7c 100644 --- a/MareSynchronos/Services/PluginWarningNotificationService.cs +++ b/MareSynchronos/Services/PluginWarningNotificationService.cs @@ -56,7 +56,7 @@ public class PluginWarningNotificationService { _mediator.Publish(new NotificationMessage("Missing plugins for " + playerName, $"Received data for {playerName} that contained information for plugins you have not installed. Install {string.Join(", ", missingPluginsForData)} to experience their character fully.", - NotificationType.Warning, 10000)); + NotificationType.Warning, TimeSpan.FromSeconds(10))); } } } \ No newline at end of file diff --git a/MareSynchronos/WebAPI/SignalR/ApiController.Functions.Callbacks.cs b/MareSynchronos/WebAPI/SignalR/ApiController.Functions.Callbacks.cs index 18c47f6..2f2d883 100644 --- a/MareSynchronos/WebAPI/SignalR/ApiController.Functions.Callbacks.cs +++ b/MareSynchronos/WebAPI/SignalR/ApiController.Functions.Callbacks.cs @@ -95,11 +95,11 @@ public partial class ApiController switch (messageSeverity) { case MessageSeverity.Error: - Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Error, 7500)); + Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Error, TimeSpan.FromSeconds(7.5))); break; case MessageSeverity.Warning: - Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Warning, 7500)); + Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Warning, TimeSpan.FromSeconds(7.5))); break; case MessageSeverity.Information: @@ -108,7 +108,7 @@ public partial class ApiController _doNotNotifyOnNextInfo = false; break; } - Mediator.Publish(new NotificationMessage("Info from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Info, 5000)); + Mediator.Publish(new NotificationMessage("Info from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Info, TimeSpan.FromSeconds(5))); break; } diff --git a/MareSynchronos/WebAPI/SignalR/ApiController.cs b/MareSynchronos/WebAPI/SignalR/ApiController.cs index eea2cd4..9770214 100644 --- a/MareSynchronos/WebAPI/SignalR/ApiController.cs +++ b/MareSynchronos/WebAPI/SignalR/ApiController.cs @@ -194,7 +194,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM $"Your client is outdated ({currentClientVer.Major}.{currentClientVer.Minor}.{currentClientVer.Build}), current is: " + $"{_connectionDto.CurrentClientVersion.Major}.{_connectionDto.CurrentClientVersion.Minor}.{_connectionDto.CurrentClientVersion.Build}. " + $"Please keep your Loporrit client up-to-date.", - NotificationType.Warning)); + NotificationType.Warning, TimeSpan.FromSeconds(15))); } await LoadIninitialPairs().ConfigureAwait(false); diff --git a/MareSynchronos/WebAPI/SignalR/Utils/ForeverRetryPolicy.cs b/MareSynchronos/WebAPI/SignalR/Utils/ForeverRetryPolicy.cs index 58796af..7dc62e1 100644 --- a/MareSynchronos/WebAPI/SignalR/Utils/ForeverRetryPolicy.cs +++ b/MareSynchronos/WebAPI/SignalR/Utils/ForeverRetryPolicy.cs @@ -28,7 +28,7 @@ public class ForeverRetryPolicy : IRetryPolicy { if (!_sentDisconnected) { - _mediator.Publish(new NotificationMessage("Connection lost", "Connection lost to server", NotificationType.Warning, 5000)); + _mediator.Publish(new NotificationMessage("Connection lost", "Connection lost to server", NotificationType.Warning, TimeSpan.FromSeconds(10))); _mediator.Publish(new DisconnectedMessage()); } _sentDisconnected = true;