feat: batch config saves

This commit is contained in:
goat 2022-11-01 19:43:38 +01:00
parent 4769239b19
commit 9c16359914
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
17 changed files with 69 additions and 37 deletions

View file

@ -179,7 +179,7 @@ internal class DalamudCommands : IServiceType
configuration.BadWords.Add(arguments);
configuration.Save();
configuration.QueueSave();
chatGui.Print(string.Format(Loc.Localize("DalamudMuted", "Muted \"{0}\"."), arguments));
}
@ -197,7 +197,7 @@ internal class DalamudCommands : IServiceType
return;
}
configuration.Save();
configuration.QueueSave();
foreach (var word in configuration.BadWords)
chatGui.Print($"\"{word}\"");
@ -212,7 +212,7 @@ internal class DalamudCommands : IServiceType
configuration.BadWords.RemoveAll(x => x == arguments);
configuration.Save();
configuration.QueueSave();
chatGui.Print(string.Format(Loc.Localize("DalamudUnmuted", "Unmuted \"{0}\"."), arguments));
}
@ -354,7 +354,7 @@ internal class DalamudCommands : IServiceType
chatGui.Print(string.Format(Loc.Localize("DalamudLanguageSetTo", "Language set to {0}"), "default"));
}
configuration.Save();
configuration.QueueSave();
}
private void OnOpenSettingsCommand(string command, string arguments)

View file

@ -515,7 +515,7 @@ internal class DalamudInterface : IDisposable, IServiceType
if (ImGui.MenuItem("Draw dev menu at startup", string.Empty, ref devBarAtStartup))
{
configuration.DevBarOpenAtStartup ^= true;
configuration.Save();
configuration.QueueSave();
}
ImGui.Separator();
@ -533,7 +533,7 @@ internal class DalamudInterface : IDisposable, IServiceType
{
EntryPoint.LogLevelSwitch.MinimumLevel = logLevel;
configuration.LogLevel = logLevel;
configuration.Save();
configuration.QueueSave();
}
}
@ -544,7 +544,7 @@ internal class DalamudInterface : IDisposable, IServiceType
if (ImGui.MenuItem("Log Synchronously", null, ref logSynchronously))
{
configuration.LogSynchronously = logSynchronously;
configuration.Save();
configuration.QueueSave();
var startupInfo = Service<DalamudStartInfo>.Get();
EntryPoint.InitLogging(
@ -563,7 +563,7 @@ internal class DalamudInterface : IDisposable, IServiceType
antiDebug.Disable();
configuration.IsAntiAntiDebugEnabled = newEnabled;
configuration.Save();
configuration.QueueSave();
}
ImGui.Separator();
@ -693,7 +693,7 @@ internal class DalamudInterface : IDisposable, IServiceType
if (ImGui.MenuItem("Enable asserts at startup", null, configuration.AssertsEnabledAtStartup))
{
configuration.AssertsEnabledAtStartup = !configuration.AssertsEnabledAtStartup;
configuration.Save();
configuration.QueueSave();
}
if (ImGui.MenuItem("Clear focus"))

View file

@ -484,7 +484,7 @@ internal class InterfaceManager : IDisposable, IServiceType
{
style = StyleModelV1.DalamudStandard;
configuration.ChosenStyle = style.Name;
configuration.Save();
configuration.QueueSave();
}
style.Apply();

View file

@ -88,7 +88,7 @@ public class BranchSwitcherWindow : Window
var config = Service<DalamudConfiguration>.Get();
config.DalamudBetaKind = pickedBranch.Key;
config.DalamudBetaKey = pickedBranch.Value.Key;
config.Save();
config.QueueSave();
}
if (ImGui.Button("Pick"))

View file

@ -130,13 +130,13 @@ internal class ConsoleWindow : Window, IDisposable
if (ImGui.Checkbox("Auto-scroll", ref this.autoScroll))
{
configuration.LogAutoScroll = this.autoScroll;
configuration.Save();
configuration.QueueSave();
}
if (ImGui.Checkbox("Open at startup", ref this.openAtStartup))
{
configuration.LogOpenAtStartup = this.openAtStartup;
configuration.Save();
configuration.QueueSave();
}
var prevLevel = (int)EntryPoint.LogLevelSwitch.MinimumLevel;
@ -144,7 +144,7 @@ internal class ConsoleWindow : Window, IDisposable
{
EntryPoint.LogLevelSwitch.MinimumLevel = (LogEventLevel)prevLevel;
configuration.LogLevel = (LogEventLevel)prevLevel;
configuration.Save();
configuration.QueueSave();
}
ImGui.EndPopup();

View file

@ -207,7 +207,7 @@ internal class PluginInstallerWindow : Window, IDisposable
/// <inheritdoc/>
public override void OnClose()
{
Service<DalamudConfiguration>.Get().Save();
Service<DalamudConfiguration>.Get().QueueSave();
}
/// <inheritdoc/>
@ -477,7 +477,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (ImGui.Button(closeText))
{
this.IsOpen = false;
configuration.Save();
configuration.QueueSave();
}
}
@ -1834,7 +1834,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (ImGui.Selectable(Locs.PluginContext_MarkAllSeen))
{
configuration.SeenPluginInternalName.AddRange(this.pluginListAvailable.Select(x => x.InternalName));
configuration.Save();
configuration.QueueSave();
pluginManager.RefilterPluginMasters();
}
@ -1842,7 +1842,7 @@ internal class PluginInstallerWindow : Window, IDisposable
{
Log.Debug($"Adding {manifest.InternalName} to hidden plugins");
configuration.HiddenPluginInternalName.Add(manifest.InternalName);
configuration.Save();
configuration.QueueSave();
pluginManager.RefilterPluginMasters();
}
@ -2146,7 +2146,7 @@ internal class PluginInstallerWindow : Window, IDisposable
configuration.PluginTestingOptIns!.Add(new PluginTestingOptIn(plugin.Manifest.InternalName));
}
configuration.Save();
configuration.QueueSave();
}
if (repoManifest?.IsTestingExclusive == true)
@ -2419,7 +2419,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (ImGuiComponents.IconButton(FontAwesomeIcon.PowerOff))
{
plugin.StartOnBoot ^= true;
configuration.Save();
configuration.QueueSave();
}
ImGui.PopStyleColor(2);
@ -2437,7 +2437,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (ImGuiComponents.IconButton(FontAwesomeIcon.SyncAlt))
{
plugin.AutomaticReload ^= true;
configuration.Save();
configuration.QueueSave();
}
ImGui.PopStyleColor(2);

View file

@ -974,7 +974,7 @@ internal class SettingsWindow : Window
configuration.DoButtonsSystemMenu = this.doButtonsSystemMenu;
configuration.DisableRmtFiltering = this.disableRmtFiltering;
configuration.Save();
configuration.QueueSave();
_ = Service<PluginManager>.Get().ReloadPluginMastersAsync();
Service<InterfaceManager>.Get().RebuildFonts();

View file

@ -105,7 +105,7 @@ public class StyleEditorWindow : Window
newStyle.Apply();
appliedThisFrame = true;
config.Save();
config.QueueSave();
}
ImGui.SameLine();
@ -119,7 +119,7 @@ public class StyleEditorWindow : Window
config.SavedStyles.RemoveAt(this.currentSel + 1);
config.Save();
config.QueueSave();
}
if (ImGui.IsItemHovered())
@ -180,7 +180,7 @@ public class StyleEditorWindow : Window
this.currentSel = config.SavedStyles.Count - 1;
config.Save();
config.QueueSave();
}
catch (Exception ex)
{
@ -366,7 +366,7 @@ public class StyleEditorWindow : Window
if (ImGui.Button("OK", new Vector2(buttonWidth, 40)))
{
config.SavedStyles[this.currentSel].Name = this.renameText;
config.Save();
config.QueueSave();
ImGui.CloseCurrentPopup();
}
@ -396,6 +396,6 @@ public class StyleEditorWindow : Window
config.SavedStyles[this.currentSel] = newStyle;
newStyle.Apply();
config.Save();
config.QueueSave();
}
}

View file

@ -93,7 +93,7 @@ public abstract class StyleModel
Log.Information("Transferred {NumStyles} styles", configuration.SavedStyles.Count);
configuration.SavedStylesOld = null;
configuration.Save();
configuration.QueueSave();
}
/// <summary>