[PTRun]Don't clear config data on upgrade (#30187)

* [PTRun] Implemented a new JSON storage method for PTRun settings files.

* [PTRun] Removed uncessary parts.

* [PTRun] Spell checks.

* [PTRun] New JsonSerializerOptions added for information files.

* [PTRun] Unnecessary null check is removed.

* [PT Run] - ExtractFields function removed.
- Creating instance is used instead of deserializing.

* [PTRun] Build fix

* [PTRun] Removed unncessary parts

* [PTRun] CheckWithInformationFileToClear reversed.

* [PTRun] Build fix.

* [PTRun] Deserialization is used instead of key by key comparison.

* [PTRun] Removed unncessary parts.

* [PTRun] Removed unncessary parts.

* [PTRun] Remove entry if query is null or empty.
This commit is contained in:
gokcekantarci
2024-02-06 18:33:19 +03:00
committed by GitHub
parent 4426df671e
commit 1c7c100a42
7 changed files with 174 additions and 28 deletions

View File

@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
namespace Wox.Plugin
@@ -73,6 +74,34 @@ namespace Wox.Plugin
}
}
public void Update()
{
foreach (var key in Records.Keys.ToList())
{
// Check if any of the specified fields are empty
if (string.IsNullOrEmpty(Records[key].IconPath) ||
string.IsNullOrEmpty(Records[key].Title) ||
string.IsNullOrEmpty(Records[key].SubTitle) ||
string.IsNullOrEmpty(Records[key].Search) ||
string.IsNullOrEmpty(Records[key].PluginID))
{
Records.Remove(key);
}
else
{
if (Records[key].SelectedCount == 0)
{
Records[key].SelectedCount = 1;
}
if (Records[key].LastSelected == DateTime.MinValue)
{
Records[key].LastSelected = DateTime.UtcNow;
}
}
}
}
public UserSelectedRecordItem GetSelectedData(Result result)
{
ArgumentNullException.ThrowIfNull(result);