From e6a91a9959d3e07d6d8f315f1ee781b93f6935f1 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 5 Jan 2026 20:17:12 +0800 Subject: [PATCH] Ensure history items have valid icons in QueryHistory Added CheckIcoPathValidity to QueryHistory to set default icons for history items missing IcoPath, addressing legacy data issues. Integrated this check into MainViewModel's RefreshLastOpenedHistoryResults to guarantee icon validity before updating absolute paths. --- Flow.Launcher/Storage/QueryHistory.cs | 18 ++++++++++++++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs index d612c81d0..0622248fb 100644 --- a/Flow.Launcher/Storage/QueryHistory.cs +++ b/Flow.Launcher/Storage/QueryHistory.cs @@ -51,6 +51,24 @@ namespace Flow.Launcher.Storage Items.Clear(); } + /// + /// Checks all items in for empty IcoPath. + /// If found, updates it using the history icon. + /// + /// + /// We need this because some prereleased version of Flow did not set the IcoPath when adding. + /// + public void CheckIcoPathValidity() + { + foreach (var item in LastOpenedHistoryItems) + { + if (string.IsNullOrEmpty(item.IcoPath)) + { + item.IcoPath = Constant.HistoryIcon; + } + } + } + /// /// Records a result into the last-opened history list (). /// This will also update the IcoPath if existing history item has one that is different. diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 65a382447..4a1a826ce 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1403,7 +1403,7 @@ namespace Flow.Launcher.ViewModel internal void RefreshLastOpenedHistoryResults() { _history.PopulateHistoryFromLegacyHistory(); - + _history.CheckIcoPathValidity(); _history.UpdateIcoPathAbsolute(); }