mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix title when query history style used
This commit is contained in:
parent
101e5e6ff1
commit
4174b5e1e4
2 changed files with 25 additions and 16 deletions
|
|
@ -28,7 +28,8 @@ namespace Flow.Launcher.Storage
|
|||
{
|
||||
LastOpenedHistoryItems.Add(new LastOpenedHistoryResult
|
||||
{
|
||||
Title = Localize.executeQuery(item.Query),
|
||||
// Title will be updated properly later on when results are re-constructed for display.
|
||||
Title = $"Legacy history item query: {item.Query}",
|
||||
IcoPath = Constant.HistoryIcon,
|
||||
OriginQuery = new Query { TrimmedQuery = item.Query },
|
||||
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C"),
|
||||
|
|
|
|||
|
|
@ -1326,6 +1326,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
||||
{
|
||||
// Items saved to disk are differentiated by Query also, but LastOpened style only cares about unique results
|
||||
historyItems = historyItems
|
||||
.GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey })
|
||||
.Select(g => g.First());
|
||||
|
|
@ -1334,28 +1335,35 @@ namespace Flow.Launcher.ViewModel
|
|||
foreach (var item in historyItems)
|
||||
{
|
||||
var copiedItem = item.DeepCopy();
|
||||
|
||||
if (Settings.HistoryStyle == HistoryStyle.Query)
|
||||
copiedItem.Title = Localize.executeQuery(copiedItem.Query);
|
||||
// Subtitle has datetime which can cause duplicates when saving.
|
||||
copiedItem.SubTitle = Localize.lastExecuteTime(item.ExecutedDateTime);
|
||||
copiedItem.SubTitle = Localize.lastExecuteTime(copiedItem.ExecutedDateTime);
|
||||
// Empty PluginID so the source of last opened history results won't be updated, these results are meant to be temporary copy.
|
||||
copiedItem.PluginID = string.Empty;
|
||||
copiedItem.AsyncAction = async c =>
|
||||
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
||||
{
|
||||
var reflectResult = await ResultHelper.PopulateResultsAsync(item);
|
||||
if (reflectResult != null)
|
||||
copiedItem.AsyncAction = async c =>
|
||||
{
|
||||
// Record the user selected record for result ranking
|
||||
_userSelectedRecord.Add(reflectResult);
|
||||
// Use original history item to reflect correct result because properties like subtitle have been modified in copiedItem
|
||||
var reflectResult = await ResultHelper.PopulateResultsAsync(item);
|
||||
if (reflectResult != null)
|
||||
{
|
||||
// Record the user selected record for result ranking
|
||||
_userSelectedRecord.Add(reflectResult);
|
||||
|
||||
// Since some actions may need to hide the Flow window to execute
|
||||
// So let us populate the results of them
|
||||
return await reflectResult.ExecuteAsync(c);
|
||||
}
|
||||
// Since some actions may need to hide the Flow window to execute
|
||||
// So let us populate the results of them
|
||||
return await reflectResult.ExecuteAsync(c);
|
||||
}
|
||||
|
||||
// If we cannot get the result, fallback to re-query
|
||||
App.API.BackToQueryResults();
|
||||
App.API.ChangeQuery(item.Query);
|
||||
return false;
|
||||
};
|
||||
// If we cannot get the result, fallback to re-query
|
||||
App.API.BackToQueryResults();
|
||||
App.API.ChangeQuery(copiedItem.Query);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
results.Add(copiedItem);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue