Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions Flow.Launcher.Plugin/Query.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Flow.Launcher.Plugin
{
public class Query
{
public Query() { }

[Obsolete("Use the default Query constructor.")]
public Query(string rawQuery, string search, string[] terms, string[] searchTerms, string actionKeyword = "")
{
Search = search;
RawQuery = rawQuery;
SearchTerms = searchTerms;
ActionKeyword = actionKeyword;
}

/// <summary>
/// Raw query, this includes action keyword if it has
/// We didn't recommend use this property directly. You should always use Search property.
Expand Down
21 changes: 16 additions & 5 deletions Flow.Launcher/Storage/TopMostRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class TopMostRecord

internal bool IsTopMost(Result result)
{
// origin query is null when user select the context menu item directly of one item from query list
// in this case, we do not need to check if the result is top most
if (records.IsEmpty || result.OriginQuery == null ||
!records.TryGetValue(result.OriginQuery.RawQuery, out var value))
{
Expand All @@ -24,11 +26,25 @@ internal bool IsTopMost(Result result)

internal void Remove(Result result)
{
// origin query is null when user select the context menu item directly of one item from query list
// in this case, we do not need to remove the record
if (result.OriginQuery == null)
{
return;
}

records.Remove(result.OriginQuery.RawQuery, out _);
}

internal void AddOrUpdate(Result result)
{
// origin query is null when user select the context menu item directly of one item from query list
// in this case, we do not need to add or update the record
if (result.OriginQuery == null)
{
return;
}

var record = new Record
{
PluginID = result.PluginID,
Expand All @@ -37,11 +53,6 @@ internal void AddOrUpdate(Result result)
};
records.AddOrUpdate(result.OriginQuery.RawQuery, record, (key, oldValue) => record);
}

public void Load(Dictionary<string, Record> dictionary)
{
records = new ConcurrentDictionary<string, Record>(dictionary);
}
}

public class Record
Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher/Storage/UserSelectedRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ private static int GenerateResultHashCode(Result result)

private static int GenerateQueryAndResultHashCode(Query query, Result result)
{
// query is null when user select the context menu item directly of one item from query list
// so we only need to consider the result
if (query == null)
{
return GenerateResultHashCode(result);
Expand Down
31 changes: 13 additions & 18 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public partial class MainViewModel : BaseModel, ISavable

private bool _isQueryRunning;
private Query _lastQuery;
private Result lastContextMenuResult = new Result();
private List<Result> lastContextMenuResults = new List<Result>();
private string _queryTextBeforeLeaveResults;

private readonly FlowLauncherJsonStorage<History> _historyItemsStorage;
Expand Down Expand Up @@ -398,11 +396,15 @@ private async Task OpenResultAsync(string index)
})
.ConfigureAwait(false);


if (SelectedIsFromQueryResults())
{
_userSelectedRecord.Add(result);
_history.Add(result.OriginQuery.RawQuery);
// origin query is null when user select the context menu item directly of one item from query list
// so we don't want to add it to history
if (result.OriginQuery != null)
{
_history.Add(result.OriginQuery.RawQuery);
}
lastHistoryIndex = 1;
}

Expand Down Expand Up @@ -986,19 +988,10 @@ private void QueryContextMenu()
if (selected != null) // SelectedItem returns null if selection is empty.
{
List<Result> results;
if (selected == lastContextMenuResult)
{
results = lastContextMenuResults;
}
else
{
results = PluginManager.GetContextMenusForPlugin(selected);
lastContextMenuResults = results;
lastContextMenuResult = selected;
results.Add(ContextMenuTopMost(selected));
results.Add(ContextMenuPluginInfo(selected.PluginID));
}

results = PluginManager.GetContextMenusForPlugin(selected);
results.Add(ContextMenuTopMost(selected));
results.Add(ContextMenuPluginInfo(selected.PluginID));

if (!string.IsNullOrEmpty(query))
{
Expand Down Expand Up @@ -1273,6 +1266,8 @@ private Result ContextMenuTopMost(Result result)
{
_topMostRecord.Remove(result);
App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success"));
App.API.BackToQueryResults();
App.API.ReQuery();
return false;
}
};
Expand All @@ -1289,6 +1284,8 @@ private Result ContextMenuTopMost(Result result)
{
_topMostRecord.AddOrUpdate(result);
App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success"));
App.API.BackToQueryResults();
App.API.ReQuery();
return false;
}
};
Expand Down Expand Up @@ -1377,8 +1374,6 @@ public async void Hide()
lastHistoryIndex = 1;
// Trick for no delay
MainWindowOpacity = 0;
lastContextMenuResult = new Result();
lastContextMenuResults = new List<Result>();

if (ExternalPreviewVisible)
CloseExternalPreview();
Expand Down
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
var name = "Plugin: Folder";
var message = $"File not found: {e.Message}";
Context.API.ShowMsgError(name, message);
return false;
}

return true;
Expand Down
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"卸載",//zh-tw
"видалити",//uk-UA
"удалить",//ru
"désinstaller",//fr

Check notice on line 51 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Line` matches candidate pattern `[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*` (candidate-pattern)
"アンインストール",//ja
"deïnstalleren",//nl
"odinstaluj",//pl
Expand Down Expand Up @@ -264,6 +264,8 @@
Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
Context.API.GetTranslation(
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
Context.API.BackToQueryResults();
Context.API.ReQuery();
return false;
},
IcoPath = "Images/disable.png",
Expand Down
Loading