mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Code cleanup
This commit is contained in:
parent
216b6f536f
commit
5f992352ee
2 changed files with 16 additions and 13 deletions
|
|
@ -70,13 +70,15 @@ namespace Flow.Launcher.Storage
|
|||
LastOpenedHistoryItems.RemoveAt(0);
|
||||
}
|
||||
|
||||
// If the last item is the same as the current result, just update the timestamp and the icon path
|
||||
if (LastOpenedHistoryItems.Count > 0 &&
|
||||
TryGetLastOpenedHistoryResult(result, out var existingHistoryItem))
|
||||
{
|
||||
existingHistoryItem.ExecutedDateTime = DateTime.Now;
|
||||
|
||||
if (existingHistoryItem.IcoPath != result.IcoPath)
|
||||
{
|
||||
existingHistoryItem.IcoPath = result.IcoPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -102,17 +104,14 @@ namespace Flow.Launcher.Storage
|
|||
/// <remarks> Call this after plugins are loaded/initialized.</remarks>
|
||||
public void UpdateIcoPathAbsolute()
|
||||
{
|
||||
if (LastOpenedHistoryItems.Count == 0)
|
||||
return;
|
||||
if (LastOpenedHistoryItems.Count == 0) return;
|
||||
|
||||
foreach (var item in LastOpenedHistoryItems)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.PluginID))
|
||||
continue;
|
||||
if (string.IsNullOrEmpty(item.PluginID)) continue;
|
||||
|
||||
var pluginPair = PluginManager.GetPluginForId(item.PluginID);
|
||||
if (pluginPair == null)
|
||||
continue;
|
||||
if (pluginPair == null) continue;
|
||||
|
||||
item.PluginDirectory = pluginPair.Metadata.PluginDirectory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -355,11 +355,10 @@ namespace Flow.Launcher.ViewModel
|
|||
if (QueryResultsSelected())
|
||||
{
|
||||
SelectedResults = History;
|
||||
|
||||
if (SelectedResults.Results.Count > 0)
|
||||
if (History.Results.Count > 0)
|
||||
{
|
||||
SelectedResults.SelectedIndex = 0;
|
||||
SelectedResults.SelectedItem = SelectedResults.Results[0];
|
||||
History.SelectedIndex = 0;
|
||||
History.SelectedItem = History.Results[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1331,8 +1330,8 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
// 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());
|
||||
.GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey })
|
||||
.Select(g => g.First());
|
||||
}
|
||||
|
||||
foreach (var item in historyItems)
|
||||
|
|
@ -1340,11 +1339,16 @@ namespace Flow.Launcher.ViewModel
|
|||
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(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;
|
||||
|
||||
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
||||
{
|
||||
copiedItem.AsyncAction = async c =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue