From bebf6c745b02a298192aebb37d4e794270de695f Mon Sep 17 00:00:00 2001 From: cake Date: Mon, 17 Nov 2025 05:32:12 +0100 Subject: [PATCH] Fixed not clickable notifications --- LightlessSync/FileCache/FileCacheManager.cs | 8 ++++---- LightlessSync/UI/LightlessNotificationUI.cs | 9 ++++++--- LightlessSync/Utils/Crypto.cs | 13 ++++++++----- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/LightlessSync/FileCache/FileCacheManager.cs b/LightlessSync/FileCache/FileCacheManager.cs index 40feede..c0a1bf3 100644 --- a/LightlessSync/FileCache/FileCacheManager.cs +++ b/LightlessSync/FileCache/FileCacheManager.cs @@ -578,13 +578,13 @@ public sealed class FileCacheManager : IHostedService { if (!File.Exists(_csvPath)) { - File.WriteAllLines(_csvPath, new[] { BuildVersionHeader(), entity.CsvEntry }); + File.WriteAllLines(_csvPath, [BuildVersionHeader(), entity.CsvEntry]); _csvHeaderEnsured = true; } else { EnsureCsvHeaderLockedCached(); - File.AppendAllLines(_csvPath, new[] { entity.CsvEntry }); + File.AppendAllLines(_csvPath, [entity.CsvEntry]); } } var result = GetFileCacheByPath(fileInfo.FullName); @@ -721,7 +721,7 @@ public sealed class FileCacheManager : IHostedService BackupUnsupportedCache("invalid-version"); parseEntries = false; rewriteRequired = true; - entries = Array.Empty(); + entries = []; } else if (parsedVersion != FileCacheVersion) { @@ -729,7 +729,7 @@ public sealed class FileCacheManager : IHostedService BackupUnsupportedCache($"v{parsedVersion}"); parseEntries = false; rewriteRequired = true; - entries = Array.Empty(); + entries = []; } else { diff --git a/LightlessSync/UI/LightlessNotificationUI.cs b/LightlessSync/UI/LightlessNotificationUI.cs index 64fe3a2..bdbe8df 100644 --- a/LightlessSync/UI/LightlessNotificationUI.cs +++ b/LightlessSync/UI/LightlessNotificationUI.cs @@ -43,7 +43,6 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoCollapse | - ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.AlwaysAutoResize; @@ -382,9 +381,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase private void HandleClickToDismiss(LightlessNotification notification) { - if (ImGui.IsWindowHovered() && + var pos = ImGui.GetWindowPos(); + var size = ImGui.GetWindowSize(); + bool hovered = ImGui.IsMouseHoveringRect(pos, new Vector2(pos.X + size.X, pos.Y + size.Y)); + + if ((hovered || ImGui.IsWindowHovered()) && _configService.Current.DismissNotificationOnClick && - !notification.Actions.Any() && + notification.Actions.Count == 0 && ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { notification.IsDismissed = true; diff --git a/LightlessSync/Utils/Crypto.cs b/LightlessSync/Utils/Crypto.cs index 0e8879f..25215c0 100644 --- a/LightlessSync/Utils/Crypto.cs +++ b/LightlessSync/Utils/Crypto.cs @@ -12,12 +12,14 @@ public static class Crypto private static readonly Dictionary<(string, ushort), string> _hashListPlayersSHA256 = []; private static readonly Dictionary _hashListSHA256 = new(StringComparer.Ordinal); private static readonly SHA256CryptoServiceProvider _sha256CryptoProvider = new(); - + public static string GetFileHash(this string filePath) { - using SHA1 sha1 = SHA1.Create(); - using FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); - return Convert.ToHexString(sha1.ComputeHash(stream)); + using var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); + using var sha1 = SHA1.Create(); + + var hash = sha1.ComputeHash(stream); + return Convert.ToHexString(hash); } public static async Task GetFileHashAsync(string filePath, CancellationToken cancellationToken = default) @@ -29,7 +31,8 @@ public static class Crypto var buffer = new byte[8192]; int bytesRead; - while ((bytesRead = await stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false)) > 0) + + while ((bytesRead = await stream.ReadAsync(buffer.AsMemory(0, buffer.Length), cancellationToken).ConfigureAwait(false)) > 0) { sha1.TransformBlock(buffer, 0, bytesRead, outputBuffer: null, 0); }