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);
|
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 &&
|
if (LastOpenedHistoryItems.Count > 0 &&
|
||||||
TryGetLastOpenedHistoryResult(result, out var existingHistoryItem))
|
TryGetLastOpenedHistoryResult(result, out var existingHistoryItem))
|
||||||
{
|
{
|
||||||
existingHistoryItem.ExecutedDateTime = DateTime.Now;
|
existingHistoryItem.ExecutedDateTime = DateTime.Now;
|
||||||
|
|
||||||
if (existingHistoryItem.IcoPath != result.IcoPath)
|
if (existingHistoryItem.IcoPath != result.IcoPath)
|
||||||
|
{
|
||||||
existingHistoryItem.IcoPath = result.IcoPath;
|
existingHistoryItem.IcoPath = result.IcoPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -102,17 +104,14 @@ namespace Flow.Launcher.Storage
|
||||||
/// <remarks> Call this after plugins are loaded/initialized.</remarks>
|
/// <remarks> Call this after plugins are loaded/initialized.</remarks>
|
||||||
public void UpdateIcoPathAbsolute()
|
public void UpdateIcoPathAbsolute()
|
||||||
{
|
{
|
||||||
if (LastOpenedHistoryItems.Count == 0)
|
if (LastOpenedHistoryItems.Count == 0) return;
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var item in LastOpenedHistoryItems)
|
foreach (var item in LastOpenedHistoryItems)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(item.PluginID))
|
if (string.IsNullOrEmpty(item.PluginID)) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
var pluginPair = PluginManager.GetPluginForId(item.PluginID);
|
var pluginPair = PluginManager.GetPluginForId(item.PluginID);
|
||||||
if (pluginPair == null)
|
if (pluginPair == null) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
item.PluginDirectory = pluginPair.Metadata.PluginDirectory;
|
item.PluginDirectory = pluginPair.Metadata.PluginDirectory;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -355,11 +355,10 @@ namespace Flow.Launcher.ViewModel
|
||||||
if (QueryResultsSelected())
|
if (QueryResultsSelected())
|
||||||
{
|
{
|
||||||
SelectedResults = History;
|
SelectedResults = History;
|
||||||
|
if (History.Results.Count > 0)
|
||||||
if (SelectedResults.Results.Count > 0)
|
|
||||||
{
|
{
|
||||||
SelectedResults.SelectedIndex = 0;
|
History.SelectedIndex = 0;
|
||||||
SelectedResults.SelectedItem = SelectedResults.Results[0];
|
History.SelectedItem = History.Results[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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
|
// Items saved to disk are differentiated by Query also, but LastOpened style only cares about unique results
|
||||||
historyItems = historyItems
|
historyItems = historyItems
|
||||||
.GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey })
|
.GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey })
|
||||||
.Select(g => g.First());
|
.Select(g => g.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in historyItems)
|
foreach (var item in historyItems)
|
||||||
|
|
@ -1340,11 +1339,16 @@ namespace Flow.Launcher.ViewModel
|
||||||
var copiedItem = item.DeepCopy();
|
var copiedItem = item.DeepCopy();
|
||||||
|
|
||||||
if (Settings.HistoryStyle == HistoryStyle.Query)
|
if (Settings.HistoryStyle == HistoryStyle.Query)
|
||||||
|
{
|
||||||
copiedItem.Title = Localize.executeQuery(copiedItem.Query);
|
copiedItem.Title = Localize.executeQuery(copiedItem.Query);
|
||||||
|
}
|
||||||
|
|
||||||
// Subtitle has datetime which can cause duplicates when saving.
|
// Subtitle has datetime which can cause duplicates when saving.
|
||||||
copiedItem.SubTitle = Localize.lastExecuteTime(copiedItem.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.
|
// 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.PluginID = string.Empty;
|
||||||
|
|
||||||
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
||||||
{
|
{
|
||||||
copiedItem.AsyncAction = async c =>
|
copiedItem.AsyncAction = async c =>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue