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.
This commit is contained in:
Jack251970 2026-01-05 20:17:12 +08:00
parent f22b6449d4
commit e6a91a9959
2 changed files with 19 additions and 1 deletions

View file

@ -51,6 +51,24 @@ namespace Flow.Launcher.Storage
Items.Clear();
}
/// <summary>
/// Checks all items in <see cref="LastOpenedHistoryItems"/> for empty IcoPath.
/// If found, updates it using the history icon.
/// </summary>
/// <remarks>
/// We need this because some prereleased version of Flow did not set the IcoPath when adding.
/// </remarks>
public void CheckIcoPathValidity()
{
foreach (var item in LastOpenedHistoryItems)
{
if (string.IsNullOrEmpty(item.IcoPath))
{
item.IcoPath = Constant.HistoryIcon;
}
}
}
/// <summary>
/// Records a result into the last-opened history list (<see cref="LastOpenedHistoryItems"/>).
/// This will also update the IcoPath if existing history item has one that is different.

View file

@ -1403,7 +1403,7 @@ namespace Flow.Launcher.ViewModel
internal void RefreshLastOpenedHistoryResults()
{
_history.PopulateHistoryFromLegacyHistory();
_history.CheckIcoPathValidity();
_history.UpdateIcoPathAbsolute();
}