diff --git a/Flow.Launcher/Storage/History.cs b/Flow.Launcher/Storage/History.cs index 5b69df056..b7ee83480 100644 --- a/Flow.Launcher/Storage/History.cs +++ b/Flow.Launcher/Storage/History.cs @@ -10,9 +10,14 @@ namespace Flow.Launcher.Storage public class History { //Legacy - [JsonInclude] public List Items { get; private set; } = []; - [JsonInclude] public List LastOpenedHistoryItems { get; private set; } = []; - [JsonInclude] public List QueryHistoryItems { get; private set; } = []; + [JsonInclude] + public List Items { get; private set; } = []; + + [JsonInclude] + public List LastOpenedHistoryItems { get; private set; } = []; + + [JsonInclude] + public List QueryHistoryItems { get; private set; } = []; private int _maxHistory = 300; @@ -20,7 +25,7 @@ namespace Flow.Launcher.Storage { if (!settings.ShowHistoryOnHomePage) return; if (settings.ShowHistoryQueryResultsForHomePage) - { + { AddLastQuery(result); return; } @@ -28,7 +33,7 @@ namespace Flow.Launcher.Storage } - public List GetHistoryItems(Settings settings) + public List GetHistoryItems(Settings settings) { if (settings.ShowHistoryQueryResultsForHomePage) return QueryHistoryItems.PopulateActions(true); return LastOpenedHistoryItems.PopulateActions(false); @@ -48,8 +53,6 @@ namespace Flow.Launcher.Storage if (Items.Count > 0) Items.Clear(); } - - private void AddLastQuery(Result result) { if (string.IsNullOrEmpty(result.OriginQuery.RawQuery)) return; @@ -83,11 +86,11 @@ namespace Flow.Launcher.Storage RawQuery = result.OriginQuery.RawQuery, RecordKey = result.RecordKey, ExecutedDateTime = DateTime.Now, - ExecuteAction = result.Action + ExecuteAction = result.Action }; var existing = LastOpenedHistoryItems. - FirstOrDefault(x => x.Title == item.Title && x.PluginID == item.PluginID); + FirstOrDefault(x => x.Title == item.Title && x.PluginID == item.PluginID); if (existing != null) diff --git a/Flow.Launcher/Storage/HistoryItem.cs b/Flow.Launcher/Storage/HistoryItem.cs index dc058c960..dcace8130 100644 --- a/Flow.Launcher/Storage/HistoryItem.cs +++ b/Flow.Launcher/Storage/HistoryItem.cs @@ -1,9 +1,9 @@ using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Flow.Launcher.Plugin; namespace Flow.Launcher.Storage; + public class HistoryItem { public string Title { get; set; } = string.Empty; @@ -11,13 +11,11 @@ public class HistoryItem public string PluginID { get; set; } = string.Empty; public string RawQuery { get; set; } public string RecordKey { get; set; } = string.Empty; - public DateTime ExecutedDateTime { get; set; } + [JsonIgnore] public Func ExecuteAction { get; set; } + [JsonIgnore] public Func QueryAction { get; set; } - - - } diff --git a/Flow.Launcher/Storage/HistoryItemLegacy.cs b/Flow.Launcher/Storage/HistoryItemLegacy.cs index 1ae62ff9e..e1e0a12ae 100644 --- a/Flow.Launcher/Storage/HistoryItemLegacy.cs +++ b/Flow.Launcher/Storage/HistoryItemLegacy.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Flow.Launcher.Storage; + +[Obsolete] public class HistoryItemLegacy { public string Query { get; set; } public DateTime? ExecutedDateTime { get; set; } - } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 45c471527..f378ff39f 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -8,8 +8,8 @@ using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; using System.Windows; -using System.Windows.Input; using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; using CommunityToolkit.Mvvm.DependencyInjection; @@ -1280,9 +1280,9 @@ namespace Flow.Launcher.ViewModel if (!match.IsSearchPrecisionScoreMet()) return false; - r.Score = match.Score; - return true; - }).ToList(); + r.Score = match.Score; + return true; + }).ToList(); ContextMenu.AddResults(filtered, id); } else @@ -1308,7 +1308,7 @@ namespace Flow.Launcher.ViewModel ( r => App.API.FuzzySearch(query, r.Title).IsSearchPrecisionScoreMet() || App.API.FuzzySearch(query, r.SubTitle).IsSearchPrecisionScoreMet() - ).ToList(); + ).ToList(); History.AddResults(filtered, id); } else @@ -1320,7 +1320,6 @@ namespace Flow.Launcher.ViewModel private List GetHistoryResults(IEnumerable historyItems) { var results = new List(); - foreach (var h in historyItems) { var result = new Result @@ -1336,11 +1335,10 @@ namespace Flow.Launcher.ViewModel }; results.Add(result); } - return results; } - private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, bool reSelect = true) + private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, bool reSelect = true) { _updateSource?.Cancel();