From 5e7b44d35a40e33b682dac1c1843bea6228ba46f Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Sun, 11 Sep 2022 10:37:46 +0900 Subject: [PATCH] Wizard behaviour has been improved --- src/ObsidianLiveSyncSettingTab.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ObsidianLiveSyncSettingTab.ts b/src/ObsidianLiveSyncSettingTab.ts index 87911f6..99523fe 100644 --- a/src/ObsidianLiveSyncSettingTab.ts +++ b/src/ObsidianLiveSyncSettingTab.ts @@ -131,10 +131,13 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { .addButton((text) => { text.setButtonText("Next").onClick(async () => { if (JSON.stringify(this.plugin.settings) != JSON.stringify(DEFAULT_SETTINGS)) { + this.plugin.localDatabase.closeReplication(); this.plugin.settings = { ...DEFAULT_SETTINGS }; this.plugin.saveSettings(); + Logger("Configuration has been flushed, please open it again", LOG_LEVEL.NOTICE) - this.hide(); + // @ts-ignore + this.plugin.app.setting.close() } else { containerEl.addClass("isWizard"); applyDisplayEnabled(); @@ -147,12 +150,12 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { .setName("Do not discard the existing configuration and set up again") .addButton((text) => { text.setButtonText("Next").onClick(async () => { - await this.plugin.resetLocalDatabase(); this.plugin.settings.liveSync = false; this.plugin.settings.periodicReplication = false; this.plugin.settings.syncOnSave = false; this.plugin.settings.syncOnStart = false; this.plugin.settings.syncOnFileOpen = false; + this.plugin.localDatabase.closeReplication(); await this.plugin.saveSettings(); containerEl.addClass("isWizard"); applyDisplayEnabled(); @@ -683,6 +686,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { new Setting(containerLocalDatabaseEl) .setName("Batch database update") .setDesc("Delay all changes, save once before replication or opening another file.") + .setClass("wizardHidden") .addToggle((toggle) => toggle.setValue(this.plugin.settings.batchSave).onChange(async (value) => { if (value && this.plugin.settings.liveSync) { @@ -1193,11 +1197,14 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { this.plugin.saveSettings(); await this.plugin.realizeSettingSyncMode(); if (inWizard) { - this.hide(); + // @ts-ignore + this.plugin.app.setting.close() await this.plugin.resetLocalDatabase(); await this.plugin.initializeDatabase(true) await this.plugin.replicate(true); - Logger("All done! Please set up subsequent devices with 'Copy setup URI' and 'Open setup URI'.", LOG_LEVEL.NOTICE) + Logger("All done! Please set up subsequent devices with 'Copy setup URI' and 'Open setup URI'.", LOG_LEVEL.NOTICE); + // @ts-ignore + this.plugin.app.commands.executeCommandById("obsidian-livesync:livesync-copysetupuri") }