From 7883e7a0a95c6609c5cf5622dfc7d4ac810c18fc Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 18 Oct 2025 10:35:23 +1100 Subject: [PATCH 1/6] add result IcoPath & Glyph + handling show badge switching --- Flow.Launcher/Storage/LastOpenedHistoryItem.cs | 2 ++ Flow.Launcher/Storage/QueryHistory.cs | 4 +++- Flow.Launcher/ViewModel/MainViewModel.cs | 10 +++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/Storage/LastOpenedHistoryItem.cs b/Flow.Launcher/Storage/LastOpenedHistoryItem.cs index 47647066c91..c7f9144a781 100644 --- a/Flow.Launcher/Storage/LastOpenedHistoryItem.cs +++ b/Flow.Launcher/Storage/LastOpenedHistoryItem.cs @@ -10,6 +10,8 @@ public class LastOpenedHistoryItem public string PluginID { get; set; } = string.Empty; public string Query { get; set; } = string.Empty; public string RecordKey { get; set; } = string.Empty; + public string IcoPath { get; set; } = string.Empty; + public GlyphInfo Glyph { get; init; } = null; public DateTime ExecutedDateTime { get; set; } public bool Equals(Result r) diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs index 8284f7eea01..bcf080669f2 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; @@ -59,6 +59,8 @@ public void Add(Result result) PluginID = result.PluginID, Query = result.OriginQuery.RawQuery, RecordKey = result.RecordKey, + IcoPath = result.IcoPath, + Glyph = result.Glyph, ExecutedDateTime = DateTime.Now }); } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f0f4b257ac4..f26e0f60fbf 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -1349,7 +1349,9 @@ private List GetHistoryItems(IEnumerable historyI Localize.executeQuery(h.Query) : h.Title, SubTitle = Localize.lastExecuteTime(h.ExecutedDateTime), - IcoPath = Constant.HistoryIcon, + IcoPath = Settings.ShowBadges ? h.IcoPath : Constant.HistoryIcon, + BadgeIcoPath = Settings.ShowBadges ? Constant.HistoryIcon : h.IcoPath, + ShowBadge = Settings.ShowBadges, OriginQuery = new Query { RawQuery = h.Query }, AsyncAction = async c => { @@ -1369,7 +1371,9 @@ private List GetHistoryItems(IEnumerable historyI App.API.ChangeQuery(h.Query); return false; }, - Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C") + Glyph = Settings.ShowBadges ? + h.Glyph is not null ? h.Glyph : null + : new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C") }; results.Add(result); } From 10d3ba268dd216b41113c762604668b3dd276bcc Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 19 Oct 2025 20:22:03 +1100 Subject: [PATCH 2/6] update history result icon display logic & remove badge icon logic --- Flow.Launcher/ViewModel/MainViewModel.cs | 46 +++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f26e0f60fbf..b8d56a6521a 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -1318,15 +1318,24 @@ private void QueryHistory() private List GetHistoryItems(IEnumerable historyItems) { var results = new List(); - if (Settings.HistoryStyle == HistoryStyle.Query) + foreach (var h in historyItems) { - foreach (var h in historyItems) + Result result = null; + var glyph = h.Glyph is null && !string.IsNullOrEmpty(h.IcoPath) // Some plugins won't have Glyph, then prefer IcoPath + ? null + : h.Glyph is not null + ? h.Glyph + : new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C"); // Default fallback + + var icoPath = !string.IsNullOrEmpty(h.IcoPath) ? h.IcoPath : Constant.HistoryIcon; + + if (Settings.HistoryStyle == HistoryStyle.Query) { - var result = new Result + result = new Result { Title = Localize.executeQuery(h.Query), SubTitle = Localize.lastExecuteTime(h.ExecutedDateTime), - IcoPath = Constant.HistoryIcon, + IcoPath = icoPath, OriginQuery = new Query { RawQuery = h.Query }, Action = _ => { @@ -1334,24 +1343,19 @@ private List GetHistoryItems(IEnumerable historyI App.API.ChangeQuery(h.Query); return false; }, - Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C") + Glyph = glyph }; - results.Add(result); } - } - else - { - foreach (var h in historyItems) + else { - var result = new Result + + result = new Result { Title = string.IsNullOrEmpty(h.Title) ? // Old migrated history items have no title - Localize.executeQuery(h.Query) : - h.Title, + Localize.executeQuery(h.Query) : + h.Title, SubTitle = Localize.lastExecuteTime(h.ExecutedDateTime), - IcoPath = Settings.ShowBadges ? h.IcoPath : Constant.HistoryIcon, - BadgeIcoPath = Settings.ShowBadges ? Constant.HistoryIcon : h.IcoPath, - ShowBadge = Settings.ShowBadges, + IcoPath = icoPath, OriginQuery = new Query { RawQuery = h.Query }, AsyncAction = async c => { @@ -1371,13 +1375,13 @@ private List GetHistoryItems(IEnumerable historyI App.API.ChangeQuery(h.Query); return false; }, - Glyph = Settings.ShowBadges ? - h.Glyph is not null ? h.Glyph : null - : new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C") + Glyph = glyph }; - results.Add(result); } + + results.Add(result); } + return results; } From 26ad47359203c120829af9c5816d9cddee67ea95 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 19 Oct 2025 21:46:02 +1100 Subject: [PATCH 3/6] 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 bcf080669f2..fde74bf17c5 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 @@ public void Add(Result result) 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 @@ public void Add(Result result) }); } } + + private bool TryGetLastOpenedHistoryResult(Result result, out LastOpenedHistoryItem historyItem) + { + historyItem = LastOpenedHistoryItems.FirstOrDefault(x => x.Equals(result)); + return historyItem is not null; + } } } From 92551c58a5d65b2d7ff6563ee9fdf75a22959043 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 21 Oct 2025 21:53:32 +1100 Subject: [PATCH 4/6] show distinct records when history style is last opened --- Flow.Launcher/ViewModel/MainViewModel.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b8d56a6521a..b70d6e5e2e2 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -1319,6 +1319,13 @@ private List GetHistoryItems(IEnumerable historyI { var results = new List(); foreach (var h in historyItems) + if (Settings.HistoryStyle == HistoryStyle.LastOpened) + { + historyItems = historyItems + .GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey }) + .Select(g => g.First()); + } + { Result result = null; var glyph = h.Glyph is null && !string.IsNullOrEmpty(h.IcoPath) // Some plugins won't have Glyph, then prefer IcoPath From 25aa5bf2af1cd683211b9ea1829c1d80aa98a141 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 21 Oct 2025 21:54:38 +1100 Subject: [PATCH 5/6] show history result sorted descending by execution time --- Flow.Launcher/ViewModel/MainViewModel.cs | 37 ++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b70d6e5e2e2..eeb15d74e30 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -1318,7 +1318,7 @@ private void QueryHistory() private List GetHistoryItems(IEnumerable historyItems) { var results = new List(); - foreach (var h in historyItems) + if (Settings.HistoryStyle == HistoryStyle.LastOpened) { historyItems = historyItems @@ -1326,28 +1326,29 @@ private List GetHistoryItems(IEnumerable historyI .Select(g => g.First()); } + foreach (var item in historyItems.OrderByDescending(h => h.ExecutedDateTime)) { Result result = null; - var glyph = h.Glyph is null && !string.IsNullOrEmpty(h.IcoPath) // Some plugins won't have Glyph, then prefer IcoPath + var glyph = item.Glyph is null && !string.IsNullOrEmpty(item.IcoPath) // Some plugins won't have Glyph, then prefer IcoPath ? null - : h.Glyph is not null - ? h.Glyph + : item.Glyph is not null + ? item.Glyph : new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C"); // Default fallback - var icoPath = !string.IsNullOrEmpty(h.IcoPath) ? h.IcoPath : Constant.HistoryIcon; + var icoPath = !string.IsNullOrEmpty(item.IcoPath) ? item.IcoPath : Constant.HistoryIcon; if (Settings.HistoryStyle == HistoryStyle.Query) { result = new Result { - Title = Localize.executeQuery(h.Query), - SubTitle = Localize.lastExecuteTime(h.ExecutedDateTime), + Title = Localize.executeQuery(item.Query), + SubTitle = Localize.lastExecuteTime(item.ExecutedDateTime), IcoPath = icoPath, - OriginQuery = new Query { RawQuery = h.Query }, + OriginQuery = new Query { RawQuery = item.Query }, Action = _ => { App.API.BackToQueryResults(); - App.API.ChangeQuery(h.Query); + App.API.ChangeQuery(item.Query); return false; }, Glyph = glyph @@ -1358,15 +1359,15 @@ private List GetHistoryItems(IEnumerable historyI result = new Result { - Title = string.IsNullOrEmpty(h.Title) ? // Old migrated history items have no title - Localize.executeQuery(h.Query) : - h.Title, - SubTitle = Localize.lastExecuteTime(h.ExecutedDateTime), + Title = string.IsNullOrEmpty(item.Title) ? // Old migrated history items have no title + Localize.executeQuery(item.Query) : + item.Title, + SubTitle = Localize.lastExecuteTime(item.ExecutedDateTime), IcoPath = icoPath, - OriginQuery = new Query { RawQuery = h.Query }, + OriginQuery = new Query { RawQuery = item.Query }, AsyncAction = async c => { - var reflectResult = await ResultHelper.PopulateResultsAsync(h); + var reflectResult = await ResultHelper.PopulateResultsAsync(item); if (reflectResult != null) { // Record the user selected record for result ranking @@ -1379,7 +1380,7 @@ private List GetHistoryItems(IEnumerable historyI // If we cannot get the result, fallback to re-query App.API.BackToQueryResults(); - App.API.ChangeQuery(h.Query); + App.API.ChangeQuery(item.Query); return false; }, Glyph = glyph @@ -1388,7 +1389,7 @@ private List GetHistoryItems(IEnumerable historyI results.Add(result); } - + return results; } From 0f269455b1c9fac303d11bed238bd1ec14e92d44 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 21 Oct 2025 22:18:29 +1100 Subject: [PATCH 6/6] remove duplicate history item sort call --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index eeb15d74e30..08d4e0d03e2 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1326,7 +1326,7 @@ private List GetHistoryItems(IEnumerable historyI .Select(g => g.First()); } - foreach (var item in historyItems.OrderByDescending(h => h.ExecutedDateTime)) + foreach (var item in historyItems) { Result result = null; var glyph = item.Glyph is null && !string.IsNullOrEmpty(item.IcoPath) // Some plugins won't have Glyph, then prefer IcoPath