mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Remove instance logic for BinaryStorage and JsonStorage, part 1
1. part of #389 2. huge refactoring
This commit is contained in:
@@ -7,10 +7,9 @@ using Wox.Plugin;
|
||||
|
||||
namespace Wox.Storage
|
||||
{
|
||||
public class QueryHistoryStorage : JsonStrorage<QueryHistoryStorage>
|
||||
public class QueryHistory
|
||||
{
|
||||
[JsonProperty]
|
||||
private List<HistoryItem> History = new List<HistoryItem>();
|
||||
public List<HistoryItem> History = new List<HistoryItem>();
|
||||
|
||||
private int MaxHistory = 300;
|
||||
private int cursor;
|
||||
@@ -18,8 +17,6 @@ namespace Wox.Storage
|
||||
public static PluginMetadata MetaData { get; } = new PluginMetadata
|
||||
{ ID = "Query history", Name = "Query history" };
|
||||
|
||||
protected override string FileName { get; } = "QueryHistory";
|
||||
|
||||
public HistoryItem Previous()
|
||||
{
|
||||
if (History.Count == 0 || cursor == 0) return null;
|
||||
@@ -58,11 +55,6 @@ namespace Wox.Storage
|
||||
});
|
||||
}
|
||||
|
||||
if (History.Count % 5 == 0)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ using Wox.Plugin;
|
||||
|
||||
namespace Wox.Storage
|
||||
{
|
||||
public class TopMostRecordStorage : JsonStrorage<TopMostRecordStorage>
|
||||
public class TopMostRecord
|
||||
{
|
||||
public Dictionary<string, TopMostRecord> records = new Dictionary<string, TopMostRecord>();
|
||||
|
||||
protected override string FileName { get; } = "TopMostRecords";
|
||||
public Dictionary<string, Record> records = new Dictionary<string, Record>();
|
||||
|
||||
internal bool IsTopMost(Result result)
|
||||
{
|
||||
@@ -24,7 +22,6 @@ namespace Wox.Storage
|
||||
if (records.ContainsKey(result.OriginQuery.RawQuery))
|
||||
{
|
||||
records.Remove(result.OriginQuery.RawQuery);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,20 +35,18 @@ namespace Wox.Storage
|
||||
}
|
||||
else
|
||||
{
|
||||
records.Add(result.OriginQuery.RawQuery, new TopMostRecord
|
||||
records.Add(result.OriginQuery.RawQuery, new Record
|
||||
{
|
||||
PluginID = result.PluginID,
|
||||
Title = result.Title,
|
||||
SubTitle = result.SubTitle
|
||||
});
|
||||
}
|
||||
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TopMostRecord
|
||||
public class Record
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string SubTitle { get; set; }
|
||||
|
||||
@@ -5,13 +5,11 @@ using Wox.Plugin;
|
||||
|
||||
namespace Wox.Storage
|
||||
{
|
||||
public class UserSelectedRecordStorage : JsonStrorage<UserSelectedRecordStorage>
|
||||
public class UserSelectedRecord
|
||||
{
|
||||
[JsonProperty]
|
||||
private Dictionary<string, int> records = new Dictionary<string, int>();
|
||||
|
||||
protected override string FileName { get; } = "UserSelectedRecords";
|
||||
|
||||
public void Add(Result result)
|
||||
{
|
||||
if (records.ContainsKey(result.ToString()))
|
||||
@@ -22,7 +20,6 @@ namespace Wox.Storage
|
||||
{
|
||||
records.Add(result.ToString(), 1);
|
||||
}
|
||||
Save();
|
||||
}
|
||||
|
||||
public int GetSelectedCount(Result result)
|
||||
|
||||
Reference in New Issue
Block a user