Reduce redundant logs when setting flags

This commit is contained in:
pizzaboxer 2023-07-24 12:22:02 +01:00
parent d1861262fc
commit 6547118383
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -110,13 +110,19 @@ namespace Bloxstrap
{ {
if (value is null) if (value is null)
{ {
if (Prop.ContainsKey(key))
App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending");
Prop.Remove(key); Prop.Remove(key);
App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending");
} }
else else
{ {
if (Prop.ContainsKey(key))
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' from '{Prop[key]}' to '{value}' is pending");
else
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending");
Prop[key] = value.ToString()!; Prop[key] = value.ToString()!;
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending");
} }
} }
@ -157,13 +163,13 @@ namespace Bloxstrap
public string GetPresetEnum(IReadOnlyDictionary<string, string> mapping, string prefix, string value) public string GetPresetEnum(IReadOnlyDictionary<string, string> mapping, string prefix, string value)
{ {
foreach (var mode in mapping) foreach (var pair in mapping)
{ {
if (mode.Key == mapping.First().Key) if (pair.Value == "None")
continue; continue;
if (App.FastFlags.GetPreset($"{prefix}.{mode.Value}") == value) if (GetPreset($"{prefix}.{pair.Value}") == value)
return mode.Key; return pair.Key;
} }
return mapping.First().Key; return mapping.First().Key;