diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 4eddfd3..85a3689 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -7,6 +7,8 @@ export interface GitHubSyncSettings { localContentDir: string; syncStrategy: "manual" | "interval"; syncInterval: number; + syncOnStartup: boolean; + conflictHandling: "ignore" | "ask" | "overwrite"; showStatusBarItem: boolean; showDownloadRibbonButton: boolean; showUploadModifiedFilesRibbonButton: boolean; @@ -22,6 +24,8 @@ export const DEFAULT_SETTINGS: GitHubSyncSettings = { localContentDir: "", syncStrategy: "manual", syncInterval: 1, + syncOnStartup: false, + conflictHandling: "ask", showStatusBarItem: true, showDownloadRibbonButton: true, showUploadModifiedFilesRibbonButton: true, diff --git a/src/settings/tab.ts b/src/settings/tab.ts index 52cd5a8..3768731 100644 --- a/src/settings/tab.ts +++ b/src/settings/tab.ts @@ -167,6 +167,40 @@ export default class GitHubSyncSettingsTab extends PluginSettingTab { }), ); + new Setting(containerEl) + .setName("Sync on startup") + .setDesc("Download up to date files from remote on startup") + .addToggle((toggle) => { + toggle + .setValue(this.plugin.settings.syncOnStartup) + .onChange(async (value) => { + this.plugin.settings.syncOnStartup = value; + await this.plugin.saveSettings(); + }); + }); + + const conflictHandlingOptions = { + ignore: "Ignore remote file", + ask: "Ask", + overwrite: "Overwrite local file", + }; + new Setting(containerEl) + .setName("Conflict handling") + .setDesc( + `What to do in case remote and local files conflict + when downloading from GitHub repository + `, + ) + .addDropdown((dropdown) => { + dropdown + .addOptions(conflictHandlingOptions) + .setValue(this.plugin.settings.conflictHandling) + .onChange(async (value: keyof typeof conflictHandlingOptions) => { + this.plugin.settings.conflictHandling = value; + await this.plugin.saveSettings(); + }); + }); + containerEl.createEl("h2", { text: "Interface" }); new Setting(containerEl)