mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Wrap operation in one class
This commit is contained in:
parent
950a7f5f2b
commit
980b792cb3
2 changed files with 37 additions and 5 deletions
|
|
@ -1,10 +1,44 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using Flow.Launcher.Infrastructure.Storage;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
namespace Flow.Launcher.Storage
|
||||
{
|
||||
public class FlowLauncherJsonStorageTopMostRecord : ISavable
|
||||
{
|
||||
private readonly FlowLauncherJsonStorage<TopMostRecord> _topMostRecordStorage;
|
||||
|
||||
private readonly TopMostRecord _topMostRecord;
|
||||
|
||||
public FlowLauncherJsonStorageTopMostRecord()
|
||||
{
|
||||
_topMostRecordStorage = new FlowLauncherJsonStorage<TopMostRecord>();
|
||||
_topMostRecord = _topMostRecordStorage.Load();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_topMostRecordStorage.Save();
|
||||
}
|
||||
|
||||
public bool IsTopMost(Result result)
|
||||
{
|
||||
return _topMostRecord.IsTopMost(result);
|
||||
}
|
||||
|
||||
public void Remove(Result result)
|
||||
{
|
||||
_topMostRecord.Remove(result);
|
||||
}
|
||||
|
||||
public void AddOrUpdate(Result result)
|
||||
{
|
||||
_topMostRecord.AddOrUpdate(result);
|
||||
}
|
||||
}
|
||||
|
||||
public class TopMostRecord
|
||||
{
|
||||
[JsonInclude]
|
||||
|
|
|
|||
|
|
@ -37,11 +37,10 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
private readonly FlowLauncherJsonStorage<History> _historyItemsStorage;
|
||||
private readonly FlowLauncherJsonStorage<UserSelectedRecord> _userSelectedRecordStorage;
|
||||
private readonly FlowLauncherJsonStorage<TopMostRecord> _topMostRecordStorage;
|
||||
private readonly FlowLauncherJsonStorageTopMostRecord _topMostRecord;
|
||||
private readonly History _history;
|
||||
private int lastHistoryIndex = 1;
|
||||
private readonly UserSelectedRecord _userSelectedRecord;
|
||||
private readonly TopMostRecord _topMostRecord;
|
||||
|
||||
private CancellationTokenSource _updateSource;
|
||||
private CancellationToken _updateToken;
|
||||
|
|
@ -134,10 +133,9 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
_historyItemsStorage = new FlowLauncherJsonStorage<History>();
|
||||
_userSelectedRecordStorage = new FlowLauncherJsonStorage<UserSelectedRecord>();
|
||||
_topMostRecordStorage = new FlowLauncherJsonStorage<TopMostRecord>();
|
||||
_topMostRecord = new FlowLauncherJsonStorageTopMostRecord();
|
||||
_history = _historyItemsStorage.Load();
|
||||
_userSelectedRecord = _userSelectedRecordStorage.Load();
|
||||
_topMostRecord = _topMostRecordStorage.Load();
|
||||
|
||||
ContextMenu = new ResultsViewModel(Settings)
|
||||
{
|
||||
|
|
@ -1612,7 +1610,7 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
_historyItemsStorage.Save();
|
||||
_userSelectedRecordStorage.Save();
|
||||
_topMostRecordStorage.Save();
|
||||
_topMostRecord.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue