From 58b9f0c19cbff0fa202701dad68c875562829456 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 1 May 2025 13:47:35 +0800 Subject: [PATCH] Improve remove logic --- Flow.Launcher/Storage/TopMostRecord.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index 0a9921f73..47ebb4a95 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -190,13 +190,16 @@ namespace Flow.Launcher.Storage // remove the record from the bag var bag = new ConcurrentQueue(value.Where(r => !r.Equals(result))); - records[result.OriginQuery.RawQuery] = new ConcurrentBag(bag); - - // if the bag is empty, remove the bag from the dictionary - if (value.IsEmpty) + if (bag.IsEmpty) { + // if the bag is empty, remove the bag from the dictionary records.TryRemove(result.OriginQuery.RawQuery, out _); } + else + { + // change the bag in the dictionary + records[result.OriginQuery.RawQuery] = new ConcurrentBag(bag); + } } internal void AddOrUpdate(Result result)