mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 11:39:16 +08:00
Fix query history for the new result panel
This commit is contained in:
parent
d946e18fa2
commit
e3cdfe27d1
@ -473,6 +473,7 @@ namespace Wox
|
||||
|
||||
private void ResetQueryHistoryIndex()
|
||||
{
|
||||
pnlResult.RemoveResultsFor(QueryHistoryStorage.MetaData);
|
||||
QueryHistoryStorage.Instance.Reset();
|
||||
}
|
||||
private void Query(string text)
|
||||
@ -487,18 +488,18 @@ namespace Wox
|
||||
{
|
||||
if (!string.IsNullOrEmpty(keyword))
|
||||
{
|
||||
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]);
|
||||
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyword))
|
||||
{
|
||||
pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword]);
|
||||
pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword].Metadata);
|
||||
}
|
||||
else if (lastKeyword != keyword)
|
||||
{
|
||||
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]);
|
||||
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
|
||||
}
|
||||
}
|
||||
_lastQuery = query;
|
||||
@ -738,14 +739,11 @@ namespace Wox
|
||||
{
|
||||
if (history != null)
|
||||
{
|
||||
var historyMetadata = new PluginMetadata
|
||||
{
|
||||
ID = "Query history",
|
||||
Name = "Query history"
|
||||
};
|
||||
var historyMetadata = QueryHistoryStorage.MetaData;
|
||||
ChangeQueryText(history.Query, true);
|
||||
var executeQueryHistoryTitle = GetTranslation("executeQuery");
|
||||
var lastExecuteTime = GetTranslation("lastExecuteTime");
|
||||
pnlResult.RemoveResultsExcept(historyMetadata);
|
||||
UpdateResultViewInternal(new List<Result>()
|
||||
{
|
||||
new Result(){
|
||||
|
@ -40,19 +40,19 @@ namespace Wox
|
||||
|
||||
public int MaxResultsToShow { get { return UserSettingStorage.Instance.MaxResultsToShow * 50; } }
|
||||
|
||||
internal void RemoveResultsFor(PluginPair plugin)
|
||||
internal void RemoveResultsFor(PluginMetadata metadata)
|
||||
{
|
||||
lock (_resultsUpdateLock)
|
||||
{
|
||||
_results.RemoveAll(r => r.PluginID == plugin.Metadata.ID);
|
||||
_results.RemoveAll(r => r.PluginID == metadata.ID);
|
||||
}
|
||||
}
|
||||
|
||||
internal void RemoveResultsExcept(PluginPair plugin)
|
||||
internal void RemoveResultsExcept(PluginMetadata metadata)
|
||||
{
|
||||
lock (_resultsUpdateLock)
|
||||
{
|
||||
_results.RemoveAll(r => r.PluginID != plugin.Metadata.ID);
|
||||
_results.RemoveAll(r => r.PluginID != metadata.ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Storage
|
||||
{
|
||||
@ -16,6 +17,9 @@ namespace Wox.Storage
|
||||
private int MaxHistory = 300;
|
||||
private int cursor = 0;
|
||||
|
||||
public static PluginMetadata MetaData { get; } = new PluginMetadata
|
||||
{ ID = "Query history", Name = "Query history" };
|
||||
|
||||
protected override string ConfigFolder
|
||||
{
|
||||
get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); }
|
||||
@ -77,7 +81,7 @@ namespace Wox.Storage
|
||||
return History.OrderByDescending(o => o.ExecutedDateTime).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class HistoryItem
|
||||
{
|
||||
public string Query { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user