Add settings to handle conflicts and configure sync

This commit is contained in:
Silvano Cerza 2025-01-09 18:17:24 +01:00
parent b6d217daaa
commit ec51b658d4
2 changed files with 38 additions and 0 deletions

View file

@ -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,

View file

@ -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)