Improve code comments & Make classes internal

This commit is contained in:
Jack251970 2025-05-01 13:23:22 +08:00
parent 07f44f2377
commit 0673d07c2a

View file

@ -34,7 +34,7 @@ namespace Flow.Launcher.Storage
} }
catch catch
{ {
// Ignored // Ignored - Flow will delete the old data during next startup
} }
_topMostRecord = _topMostRecordStorage.Load(); _topMostRecord = _topMostRecordStorage.Load();
} }
@ -52,7 +52,7 @@ namespace Flow.Launcher.Storage
} }
catch catch
{ {
// Ignored // Ignored - Flow will delete the old data during next startup
} }
Save(); Save();
} }
@ -84,7 +84,10 @@ namespace Flow.Launcher.Storage
} }
} }
public class TopMostRecord /// <summary>
/// Old data structure to support only one top most record for the same query
/// </summary>
internal class TopMostRecord
{ {
[JsonInclude] [JsonInclude]
public ConcurrentDictionary<string, Record> records { get; private set; } = new(); public ConcurrentDictionary<string, Record> records { get; private set; } = new();
@ -135,7 +138,10 @@ namespace Flow.Launcher.Storage
} }
} }
public class MultipleTopMostRecord /// <summary>
/// New data structure to support multiple top most records for the same query
/// </summary>
internal class MultipleTopMostRecord
{ {
[JsonInclude] [JsonInclude]
[JsonConverter(typeof(ConcurrentDictionaryConcurrentBagConverter))] [JsonConverter(typeof(ConcurrentDictionaryConcurrentBagConverter))]
@ -246,7 +252,7 @@ namespace Flow.Launcher.Storage
/// <summary> /// <summary>
/// Because ConcurrentBag does not support serialization, we need to convert it to a List /// Because ConcurrentBag does not support serialization, we need to convert it to a List
/// </summary> /// </summary>
public class ConcurrentDictionaryConcurrentBagConverter : JsonConverter<ConcurrentDictionary<string, ConcurrentBag<Record>>> internal class ConcurrentDictionaryConcurrentBagConverter : JsonConverter<ConcurrentDictionary<string, ConcurrentBag<Record>>>
{ {
public override ConcurrentDictionary<string, ConcurrentBag<Record>> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override ConcurrentDictionary<string, ConcurrentBag<Record>> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
@ -270,7 +276,7 @@ namespace Flow.Launcher.Storage
} }
} }
public class Record internal class Record
{ {
public string Title { get; init; } public string Title { get; init; }
public string SubTitle { get; init; } public string SubTitle { get; init; }