mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Mark old data as obsolete
This commit is contained in:
parent
58b9f0c19c
commit
7103c8d24a
1 changed files with 13 additions and 18 deletions
|
|
@ -16,8 +16,10 @@ namespace Flow.Launcher.Storage
|
||||||
|
|
||||||
public FlowLauncherJsonStorageTopMostRecord()
|
public FlowLauncherJsonStorageTopMostRecord()
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
// Get old data & new data
|
// Get old data & new data
|
||||||
var topMostRecordStorage = new FlowLauncherJsonStorage<TopMostRecord>();
|
var topMostRecordStorage = new FlowLauncherJsonStorage<TopMostRecord>();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
_topMostRecordStorage = new FlowLauncherJsonStorage<MultipleTopMostRecord>();
|
_topMostRecordStorage = new FlowLauncherJsonStorage<MultipleTopMostRecord>();
|
||||||
|
|
||||||
// Check if data exist
|
// Check if data exist
|
||||||
|
|
@ -43,7 +45,16 @@ namespace Flow.Launcher.Storage
|
||||||
{
|
{
|
||||||
// Migrate old data to new data
|
// Migrate old data to new data
|
||||||
_topMostRecord = _topMostRecordStorage.Load();
|
_topMostRecord = _topMostRecordStorage.Load();
|
||||||
_topMostRecord.Add(topMostRecordStorage.Load());
|
var oldTopMostRecord = topMostRecordStorage.Load();
|
||||||
|
if (oldTopMostRecord == null || oldTopMostRecord.records.IsEmpty) return;
|
||||||
|
foreach (var record in oldTopMostRecord.records)
|
||||||
|
{
|
||||||
|
_topMostRecord.records.AddOrUpdate(record.Key, new ConcurrentBag<Record> { record.Value }, (key, oldValue) =>
|
||||||
|
{
|
||||||
|
oldValue.Add(record.Value);
|
||||||
|
return oldValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Delete old data and save the new data
|
// Delete old data and save the new data
|
||||||
try
|
try
|
||||||
|
|
@ -87,6 +98,7 @@ namespace Flow.Launcher.Storage
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Old data structure to support only one top most record for the same query
|
/// Old data structure to support only one top most record for the same query
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("Use MultipleTopMostRecord instead. This class will be removed in future versions.")]
|
||||||
internal class TopMostRecord
|
internal class TopMostRecord
|
||||||
{
|
{
|
||||||
[JsonInclude]
|
[JsonInclude]
|
||||||
|
|
@ -147,23 +159,6 @@ namespace Flow.Launcher.Storage
|
||||||
[JsonConverter(typeof(ConcurrentDictionaryConcurrentBagConverter))]
|
[JsonConverter(typeof(ConcurrentDictionaryConcurrentBagConverter))]
|
||||||
public ConcurrentDictionary<string, ConcurrentBag<Record>> records { get; private set; } = new();
|
public ConcurrentDictionary<string, ConcurrentBag<Record>> records { get; private set; } = new();
|
||||||
|
|
||||||
internal void Add(TopMostRecord topMostRecord)
|
|
||||||
{
|
|
||||||
if (topMostRecord == null || topMostRecord.records.IsEmpty)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var record in topMostRecord.records)
|
|
||||||
{
|
|
||||||
records.AddOrUpdate(record.Key, new ConcurrentBag<Record> { record.Value }, (key, oldValue) =>
|
|
||||||
{
|
|
||||||
oldValue.Add(record.Value);
|
|
||||||
return oldValue;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal bool IsTopMost(Result result)
|
internal bool IsTopMost(Result result)
|
||||||
{
|
{
|
||||||
// origin query is null when user select the context menu item directly of one item from query list
|
// origin query is null when user select the context menu item directly of one item from query list
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue