From 26ad47359203c120829af9c5816d9cddee67ea95 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 19 Oct 2025 21:46:02 +1100 Subject: [PATCH] change getting last history item to get the same result if exists --- Flow.Launcher/Storage/QueryHistory.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs index bcf080669..fde74bf17 100644 --- a/Flow.Launcher/Storage/QueryHistory.cs +++ b/Flow.Launcher/Storage/QueryHistory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; @@ -44,11 +44,11 @@ namespace Flow.Launcher.Storage LastOpenedHistoryItems.RemoveAt(0); } - // If the last item is the same as the current result, just update the timestamp - if (LastOpenedHistoryItems.Count > 0 && - LastOpenedHistoryItems.Last().Equals(result)) + if (LastOpenedHistoryItems.Count > 0 && + TryGetLastOpenedHistoryResult(result, out var existingHistoryItem)) { - LastOpenedHistoryItems.Last().ExecutedDateTime = DateTime.Now; + existingHistoryItem.IcoPath = result.IcoPath; + existingHistoryItem.ExecutedDateTime = DateTime.Now; } else { @@ -65,5 +65,11 @@ namespace Flow.Launcher.Storage }); } } + + private bool TryGetLastOpenedHistoryResult(Result result, out LastOpenedHistoryItem historyItem) + { + historyItem = LastOpenedHistoryItems.FirstOrDefault(x => x.Equals(result)); + return historyItem is not null; + } } }