diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
index 20b4fa016..6adefdb6a 100644
--- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
+++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs
@@ -7,6 +7,7 @@ using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Storage;
+using Flow.Launcher.Localization.Attributes;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
@@ -214,64 +215,17 @@ namespace Flow.Launcher.Infrastructure.UserSettings
}
}
}
- private bool _showHistoryOnHomePage = true;
- public bool ShowHistoryOnHomePage
+
+ private bool _showHistoryResultsForHomePage = false;
+ public bool ShowHistoryResultsForHomePage
{
- get
- {
- if (ShowHistoryQueryResultsForHomePage || ShowHistoryLastOpenedResultsForHomePage) return true;
- return _showHistoryOnHomePage;
- }
+ get => _showHistoryResultsForHomePage;
set
{
- if (_showHistoryOnHomePage != value)
+ if (_showHistoryResultsForHomePage != value)
{
- _showHistoryOnHomePage = value;
+ _showHistoryResultsForHomePage = value;
OnPropertyChanged();
- if (value == false)
- {
- ShowHistoryQueryResultsForHomePage = false;
- ShowHistoryLastOpenedResultsForHomePage = false;
- }
- }
- }
- }
-
- private bool _showHistoryQueryResultsForHomePage = true;
- public bool ShowHistoryQueryResultsForHomePage
- {
- get => _showHistoryQueryResultsForHomePage;
- set
- {
- if (_showHistoryQueryResultsForHomePage != value)
- {
- _showHistoryQueryResultsForHomePage = value;
- OnPropertyChanged();
- if (value && _showHistoryLastOpenedResultsForHomePage)
- {
- _showHistoryLastOpenedResultsForHomePage = false;
- OnPropertyChanged(nameof(ShowHistoryLastOpenedResultsForHomePage));
- }
- }
- }
- }
-
-
- private bool _showHistoryLastOpenedResultsForHomePage;
- public bool ShowHistoryLastOpenedResultsForHomePage
- {
- get => _showHistoryLastOpenedResultsForHomePage;
- set
- {
- if (_showHistoryLastOpenedResultsForHomePage != value)
- {
- _showHistoryLastOpenedResultsForHomePage = value;
- OnPropertyChanged();
- if (value && _showHistoryQueryResultsForHomePage)
- {
- _showHistoryQueryResultsForHomePage = false;
- OnPropertyChanged(nameof(ShowHistoryQueryResultsForHomePage));
- }
}
}
}
@@ -560,6 +514,21 @@ namespace Flow.Launcher.Infrastructure.UserSettings
[JsonConverter(typeof(JsonStringEnumConverter))]
public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;
+ private HistoryStyle _historyStyle = HistoryStyle.Query;
+ [JsonConverter(typeof(JsonStringEnumConverter))]
+ public HistoryStyle HistoryStyle
+ {
+ get => _historyStyle;
+ set
+ {
+ if (_historyStyle != value)
+ {
+ _historyStyle = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
[JsonConverter(typeof(JsonStringEnumConverter))]
public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium;
public int CustomAnimationLength { get; set; } = 360;
@@ -742,4 +711,14 @@ namespace Flow.Launcher.Infrastructure.UserSettings
FullPathOpen,
Directory
}
+
+ [EnumLocalize]
+ public enum HistoryStyle
+ {
+ [EnumLocalizeKey(nameof(Localize.queryHistory))]
+ Query,
+
+ [EnumLocalizeKey(nameof(Localize.executedHistory))]
+ LastOpened
+ }
}
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 0f44d77df..dd35bcc1d 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -164,13 +164,12 @@
Please check your system registry access or contact support.
Home Page
Show home page results when query text is empty.
- Home Page History
- Choose the type of history to show on the home page
- Query History
- Last Opened History
- Show Query History
- Show Last Opened History
- Maximum History Results Shown
+ Show History Results in Home Page
+ Maximum History Results Shown in Home Page
+ History Style
+ Choose the type of history to show in the history and home page
+ Query history
+ Last opened history
This can only be edited if plugin supports Home feature and Home Page is enabled.
Show Search Window at Foremost
Overrides other programs' 'Always on Top' setting and displays Flow in the foremost position.
diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs
index e05975ff8..88d6b6606 100644
--- a/Flow.Launcher/MainWindow.xaml.cs
+++ b/Flow.Launcher/MainWindow.xaml.cs
@@ -321,8 +321,8 @@ namespace Flow.Launcher
InitializeContextMenu();
break;
case nameof(Settings.ShowHomePage):
- case nameof(Settings.ShowHistoryQueryResultsForHomePage):
- case nameof(Settings.ShowHistoryLastOpenedResultsForHomePage):
+ case nameof(Settings.ShowHistoryResultsForHomePage):
+ case nameof(Settings.HistoryStyle):
if (_viewModel.QueryResultsSelected() && string.IsNullOrEmpty(_viewModel.QueryText))
{
_viewModel.QueryResults();
diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
index 6641ac689..aa78849ba 100644
--- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
@@ -147,6 +147,8 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
public List LastQueryModes { get; } =
DropdownDataGeneric.GetValues("LastQuery");
+ public List HistoryStyles { get; } = HistoryStyleLocalized.GetValues();
+
public bool EnableDialogJump
{
get => Settings.EnableDialogJump;
@@ -213,6 +215,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
DropdownDataGeneric.UpdateLabels(SearchWindowAligns);
DropdownDataGeneric.UpdateLabels(SearchPrecisionScores);
DropdownDataGeneric.UpdateLabels(LastQueryModes);
+ HistoryStyleLocalized.UpdateLabels(HistoryStyles);
DropdownDataGeneric.UpdateLabels(DoublePinyinSchemas);
DropdownDataGeneric.UpdateLabels(DialogJumpWindowPositions);
DropdownDataGeneric.UpdateLabels(DialogJumpResultBehaviours);
diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml
index ddd7747d1..0c48b511a 100644
--- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml
+++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml
@@ -13,7 +13,7 @@
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
Title="General"
d:DataContext="{d:DesignInstance settingsViewModels:SettingsPaneGeneralViewModel}"
- d:DesignHeight="450"
+ d:DesignHeight="10000"
d:DesignWidth="800"
mc:Ignorable="d">
@@ -245,6 +245,22 @@
SelectedValuePath="Value" />
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
Items { get; private set; } = [];
-
- [JsonInclude]
- public List LastOpenedHistoryItems { get; private set; } = [];
-
- [JsonInclude]
- public List QueryHistoryItems { get; private set; } = [];
-
- private int _maxHistory = 300;
-
- public void AddToHistory(Result result, Settings settings)
- {
- if (!settings.ShowHistoryOnHomePage) return;
- if (settings.ShowHistoryQueryResultsForHomePage)
- {
- AddLastQuery(result);
- return;
- }
- AddLastOpened(result);
- }
-
-
- public List GetHistoryItems(Settings settings)
- {
- if (settings.ShowHistoryQueryResultsForHomePage) return QueryHistoryItems.PopulateActions(true);
- return LastOpenedHistoryItems.PopulateActions(false);
- }
-
- public void PopulateHistoryFromLegacyHistory()
- {
- foreach (var item in Items)
- {
- QueryHistoryItems.Add(new HistoryItem
- {
- RawQuery = item.Query,
- ExecutedDateTime = item.ExecutedDateTime ?? DateTime.Now,
- QueryAction = HistoryHelper.GetQueryAction(item.Query)
- });
- }
- if (Items.Count > 0) Items.Clear();
- }
-
- private void AddLastQuery(Result result)
- {
- if (string.IsNullOrEmpty(result.OriginQuery.RawQuery)) return;
- if (QueryHistoryItems.Count > _maxHistory)
- {
- QueryHistoryItems.RemoveAt(0);
- }
-
- if (QueryHistoryItems.Count > 0 && QueryHistoryItems.Last().RawQuery == result.OriginQuery.RawQuery)
- {
- QueryHistoryItems.Last().ExecutedDateTime = DateTime.Now;
- }
- else
- {
- QueryHistoryItems.Add(new HistoryItem
- {
- RawQuery = result.OriginQuery.RawQuery,
- ExecutedDateTime = DateTime.Now,
- QueryAction = HistoryHelper.GetQueryAction(result.OriginQuery.RawQuery)
- });
- }
- }
-
- private void AddLastOpened(Result result)
- {
- var item = new HistoryItem
- {
- Title = result.Title,
- SubTitle = result.SubTitle,
- PluginID = result.PluginID,
- RawQuery = result.OriginQuery.RawQuery,
- RecordKey = result.RecordKey,
- ExecutedDateTime = DateTime.Now,
- ExecuteAction = result.Action
- };
-
- var existing = LastOpenedHistoryItems.
- FirstOrDefault(x => x.Title == item.Title && x.PluginID == item.PluginID);
-
-
- if (existing != null)
- {
- existing.ExecutedDateTime = DateTime.Now;
- }
- else
- {
- if (LastOpenedHistoryItems.Count > _maxHistory)
- {
- LastOpenedHistoryItems.RemoveAt(0);
- }
-
- LastOpenedHistoryItems.Add(item);
- }
- }
- }
-}
diff --git a/Flow.Launcher/Storage/HistoryHelper.cs b/Flow.Launcher/Storage/HistoryHelper.cs
index 2f58b5bb7..d9d0ec5a8 100644
--- a/Flow.Launcher/Storage/HistoryHelper.cs
+++ b/Flow.Launcher/Storage/HistoryHelper.cs
@@ -11,13 +11,13 @@ namespace Flow.Launcher.Storage;
public static class HistoryHelper
{
- internal static List PopulateActions(this List items, bool isQuery)
+ internal static List PopulateActions(this List items, bool isQuery)
{
foreach (var item in items)
{
if (item.QueryAction != null && item.ExecuteAction != null) continue;
- if (isQuery && item.QueryAction == null) item.QueryAction = GetQueryAction(item.RawQuery);
- if (!isQuery && item.ExecuteAction == null) item.ExecuteAction = GetExecuteAction(item.PluginID, item.RawQuery, item.Title, item.SubTitle, item.RecordKey) ?? GetQueryAction(item.RawQuery);
+ if (isQuery && item.QueryAction == null) item.QueryAction = GetQueryAction(item.Query);
+ if (!isQuery && item.ExecuteAction == null) item.ExecuteAction = GetExecuteAction(item.PluginID, item.Query, item.Title, item.SubTitle, item.RecordKey) ?? GetQueryAction(item.Query);
}
return items;
diff --git a/Flow.Launcher/Storage/HistoryItem.cs b/Flow.Launcher/Storage/HistoryItem.cs
index dcace8130..63604d2c8 100644
--- a/Flow.Launcher/Storage/HistoryItem.cs
+++ b/Flow.Launcher/Storage/HistoryItem.cs
@@ -1,21 +1,46 @@
using System;
-using System.Text.Json.Serialization;
-using Flow.Launcher.Plugin;
-namespace Flow.Launcher.Storage;
-
-public class HistoryItem
+namespace Flow.Launcher.Storage
{
- public string Title { get; set; } = string.Empty;
- public string SubTitle { get; set; } = string.Empty;
- public string PluginID { get; set; } = string.Empty;
- public string RawQuery { get; set; }
- public string RecordKey { get; set; } = string.Empty;
- public DateTime ExecutedDateTime { get; set; }
+ [Obsolete("Use LastOpenedHistoryItem instead. This class will be removed in future versions.")]
+ public class HistoryItem
+ {
+ public string Query { get; set; }
+ public DateTime ExecutedDateTime { get; set; }
- [JsonIgnore]
- public Func ExecuteAction { get; set; }
+ public string GetTimeAgo()
+ {
+ return DateTimeAgo(ExecutedDateTime);
+ }
- [JsonIgnore]
- public Func QueryAction { get; set; }
+ private string DateTimeAgo(DateTime dt)
+ {
+ var span = DateTime.Now - dt;
+ if (span.Days > 365)
+ {
+ int years = (span.Days / 365);
+ if (span.Days % 365 != 0)
+ years += 1;
+ return $"about {years} {(years == 1 ? "year" : "years")} ago";
+ }
+ if (span.Days > 30)
+ {
+ int months = (span.Days / 30);
+ if (span.Days % 31 != 0)
+ months += 1;
+ return $"about {months} {(months == 1 ? "month" : "months")} ago";
+ }
+ if (span.Days > 0)
+ return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago";
+ if (span.Hours > 0)
+ return $"about {span.Hours} {(span.Hours == 1 ? "hour" : "hours")} ago";
+ if (span.Minutes > 0)
+ return $"about {span.Minutes} {(span.Minutes == 1 ? "minute" : "minutes")} ago";
+ if (span.Seconds > 5)
+ return $"about {span.Seconds} seconds ago";
+ if (span.Seconds <= 5)
+ return "just now";
+ return string.Empty;
+ }
+ }
}
diff --git a/Flow.Launcher/Storage/HistoryItemLegacy.cs b/Flow.Launcher/Storage/HistoryItemLegacy.cs
deleted file mode 100644
index e1e0a12ae..000000000
--- a/Flow.Launcher/Storage/HistoryItemLegacy.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-
-namespace Flow.Launcher.Storage;
-
-[Obsolete]
-public class HistoryItemLegacy
-{
- public string Query { get; set; }
- public DateTime? ExecutedDateTime { get; set; }
-}
diff --git a/Flow.Launcher/Storage/LastOpenedHistoryItem.cs b/Flow.Launcher/Storage/LastOpenedHistoryItem.cs
new file mode 100644
index 000000000..c09933cc9
--- /dev/null
+++ b/Flow.Launcher/Storage/LastOpenedHistoryItem.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Text.Json.Serialization;
+using Flow.Launcher.Plugin;
+
+namespace Flow.Launcher.Storage;
+
+public class LastOpenedHistoryItem
+{
+ public string Title { get; set; } = string.Empty;
+ public string SubTitle { get; set; } = string.Empty;
+ public string PluginID { get; set; } = string.Empty;
+ public string Query { get; set; } = string.Empty;
+ public string RecordKey { get; set; } = string.Empty;
+ public DateTime ExecutedDateTime { get; set; }
+
+ [JsonIgnore]
+ public Func ExecuteAction { get; set; }
+
+ [JsonIgnore]
+ public Func QueryAction { get; set; }
+
+ public bool Equals(Result r)
+ {
+ if (string.IsNullOrEmpty(RecordKey) || string.IsNullOrEmpty(r.RecordKey))
+ {
+ return Title == r.Title
+ && SubTitle == r.SubTitle
+ && PluginID == r.PluginID
+ && Query == r.OriginQuery.RawQuery;
+ }
+ else
+ {
+ return RecordKey == r.RecordKey
+ && PluginID == r.PluginID
+ && Query == r.OriginQuery.RawQuery;
+ }
+ }
+}
diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs
new file mode 100644
index 000000000..bd23837f8
--- /dev/null
+++ b/Flow.Launcher/Storage/QueryHistory.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json.Serialization;
+using CommunityToolkit.Mvvm.DependencyInjection;
+using Flow.Launcher.Infrastructure.UserSettings;
+using Flow.Launcher.Plugin;
+
+namespace Flow.Launcher.Storage
+{
+ public class History
+ {
+ [JsonInclude]
+#pragma warning disable CS0618 // Type or member is obsolete
+ public List Items { get; private set; } = [];
+#pragma warning restore CS0618 // Type or member is obsolete
+
+ [JsonInclude]
+ public List LastOpenedHistoryItems { get; private set; } = [];
+
+ private readonly int _maxHistory = 300;
+ private static readonly Settings _settings = Ioc.Default.GetRequiredService();
+
+ public void PopulateHistoryFromLegacyHistory()
+ {
+ if (Items.Count == 0) return;
+ // Migrate old history items to new LastOpenedHistoryItems
+ foreach (var item in Items)
+ {
+ LastOpenedHistoryItems.Add(new LastOpenedHistoryItem
+ {
+ Query = item.Query,
+ ExecutedDateTime = item.ExecutedDateTime,
+ QueryAction = HistoryHelper.GetQueryAction(item.Query)
+ });
+ }
+ Items.Clear();
+ }
+
+ public void Add(Result result)
+ {
+ if (string.IsNullOrEmpty(result.OriginQuery.RawQuery)) return;
+
+ // Maintain the max history limit
+ if (LastOpenedHistoryItems.Count > _maxHistory)
+ {
+ 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))
+ {
+ LastOpenedHistoryItems.Last().ExecutedDateTime = DateTime.Now;
+ }
+ else
+ {
+ LastOpenedHistoryItems.Add(new LastOpenedHistoryItem
+ {
+ Title = result.Title,
+ SubTitle = result.SubTitle,
+ PluginID = result.PluginID,
+ Query = result.OriginQuery.RawQuery,
+ RecordKey = result.RecordKey,
+ ExecutedDateTime = DateTime.Now,
+ ExecuteAction = result.Action
+ });
+ }
+ }
+
+ public List GetHistoryItems()
+ {
+ return LastOpenedHistoryItems.PopulateActions(_settings.HistoryStyle == HistoryStyle.Query);
+ }
+ }
+}
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index f378ff39f..846b46a43 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -40,7 +40,7 @@ namespace Flow.Launcher.ViewModel
private string _queryTextBeforeLeaveResults;
private string _ignoredQueryText; // Used to ignore query text change when switching between context menu and query results
- private readonly FlowLauncherJsonStorage _historyStorage;
+ private readonly FlowLauncherJsonStorage _historyItemsStorage;
private readonly FlowLauncherJsonStorage _userSelectedRecordStorage;
private readonly FlowLauncherJsonStorageTopMostRecord _topMostRecord;
private readonly History _history;
@@ -147,12 +147,10 @@ namespace Flow.Launcher.ViewModel
}
};
- _historyStorage = new FlowLauncherJsonStorage();
-
+ _historyItemsStorage = new FlowLauncherJsonStorage();
_userSelectedRecordStorage = new FlowLauncherJsonStorage();
_topMostRecord = new FlowLauncherJsonStorageTopMostRecord();
-
- _history = _historyStorage.Load();
+ _history = _historyItemsStorage.Load();
_history.PopulateHistoryFromLegacyHistory();
_userSelectedRecord = _userSelectedRecordStorage.Load();
@@ -355,7 +353,7 @@ namespace Flow.Launcher.ViewModel
if (QueryResultsSelected())
{
SelectedResults = History;
- History.SelectedIndex = _history.GetHistoryItems(Settings).Count - 1;
+ History.SelectedIndex = _history.GetHistoryItems().Count - 1;
}
else
{
@@ -383,10 +381,10 @@ namespace Flow.Launcher.ViewModel
[RelayCommand]
public void ReverseHistory()
{
- var historyItems = _history.GetHistoryItems(Settings);
+ var historyItems = _history.GetHistoryItems();
if (historyItems.Count > 0)
{
- ChangeQueryText(historyItems[^lastHistoryIndex].RawQuery);
+ ChangeQueryText(historyItems[^lastHistoryIndex].Query);
if (lastHistoryIndex < historyItems.Count)
{
lastHistoryIndex++;
@@ -397,11 +395,10 @@ namespace Flow.Launcher.ViewModel
[RelayCommand]
public void ForwardHistory()
{
- var historyItems = _history.GetHistoryItems(Settings);
-
+ var historyItems = _history.GetHistoryItems();
if (historyItems.Count > 0)
{
- ChangeQueryText(historyItems[^lastHistoryIndex].RawQuery);
+ ChangeQueryText(historyItems[^lastHistoryIndex].Query);
if (lastHistoryIndex > 1)
{
lastHistoryIndex--;
@@ -533,11 +530,10 @@ namespace Flow.Launcher.ViewModel
Hide();
}
}
-
if (QueryResultsSelected())
{
- _history.AddToHistory(result, Settings);
_userSelectedRecord.Add(result);
+ _history.Add(result);
lastHistoryIndex = 1;
}
}
@@ -566,6 +562,7 @@ namespace Flow.Launcher.ViewModel
resultsCopy.Add(resultCopy);
}
}
+
return resultsCopy;
}
@@ -612,11 +609,11 @@ namespace Flow.Launcher.ViewModel
[RelayCommand]
private void SelectPrevItem()
{
- var historyItems = _history.GetHistoryItems(Settings);
+ var historyItems = _history.GetHistoryItems();
if (QueryResultsSelected() // Results selected
&& string.IsNullOrEmpty(QueryText) // No input
&& Results.Visibility != Visibility.Visible // No items in result list, e.g. when home page is off and no query text is entered, therefore the view is collapsed.
- && historyItems.Count > 0)
+ && historyItems.Count > 0) // Have history items
{
lastHistoryIndex = 1;
ReverseHistory();
@@ -1298,9 +1295,7 @@ namespace Flow.Launcher.ViewModel
var query = QueryText.ToLower().Trim();
History.Clear();
- var items = _history.GetHistoryItems(Settings);
-
- var results = GetHistoryResults(items);
+ var results = GetHistoryItems(_history.GetHistoryItems());
if (!string.IsNullOrEmpty(query))
{
@@ -1317,20 +1312,22 @@ namespace Flow.Launcher.ViewModel
}
}
- private List GetHistoryResults(IEnumerable historyItems)
+ private List GetHistoryItems(IEnumerable historyItems)
{
var results = new List();
foreach (var h in historyItems)
{
var result = new Result
{
- Title =
- Settings.ShowHistoryQueryResultsForHomePage ? Localize.executeQuery(h.RawQuery) : h.Title,
+ Title = Settings.HistoryStyle == HistoryStyle.Query ?
+ Localize.executeQuery(h.Query) :
+ string.IsNullOrEmpty(h.Title) ? // Old migrated history items have no title
+ Localize.executeQuery(h.Query) :
+ h.Title,
SubTitle = Localize.lastExecuteTime(h.ExecutedDateTime),
IcoPath = Constant.HistoryIcon,
- PluginID = h.PluginID,
- OriginQuery = QueryBuilder.Build(h.RawQuery, PluginManager.NonGlobalPlugins),
- Action = Settings.ShowHistoryLastOpenedResultsForHomePage ? h.ExecuteAction : h.QueryAction,
+ OriginQuery = new Query { RawQuery = h.Query },
+ Action = Settings.HistoryStyle == HistoryStyle.Query ? h.QueryAction : h.ExecuteAction,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C")
};
results.Add(result);
@@ -1452,7 +1449,8 @@ namespace Flow.Launcher.ViewModel
true => Task.CompletedTask
}).ToArray();
- if (Settings.ShowHistoryOnHomePage)
+ // Query history results for home page firstly so it will be put on top of the results
+ if (Settings.ShowHistoryResultsForHomePage)
{
QueryHistoryTask(currentCancellationToken);
}
@@ -1564,9 +1562,9 @@ namespace Flow.Launcher.ViewModel
void QueryHistoryTask(CancellationToken token)
{
// Select last history results and revert its order to make sure last history results are on top
- var historyItems = _history.GetHistoryItems(Settings).TakeLast(Settings.MaxHistoryResultsToShowForHomePage).Reverse();
+ var historyItems = _history.GetHistoryItems().TakeLast(Settings.MaxHistoryResultsToShowForHomePage).Reverse();
- var results = GetHistoryResults(historyItems);
+ var results = GetHistoryItems(historyItems);
if (token.IsCancellationRequested) return;
@@ -1702,7 +1700,7 @@ namespace Flow.Launcher.ViewModel
/// True if existing results should be cleared, false otherwise.
private bool ShouldClearExistingResultsForNonQuery(ICollection plugins)
{
- if (!Settings.ShowHistoryQueryResultsForHomePage && (plugins.Count == 0 || plugins.All(x => x.Metadata.HomeDisabled == true)))
+ if (!Settings.ShowHistoryResultsForHomePage && (plugins.Count == 0 || plugins.All(x => x.Metadata.HomeDisabled == true)))
{
App.API.LogDebug(ClassName, $"Existing results should be cleared for non-query");
return true;
@@ -2166,7 +2164,7 @@ namespace Flow.Launcher.ViewModel
///
public void Save()
{
- _historyStorage.Save();
+ _historyItemsStorage.Save();
_userSelectedRecordStorage.Save();
_topMostRecord.Save();
}