Rename some settings for clarity

This commit is contained in:
Silvano Cerza 2025-01-22 13:42:06 +01:00
parent 7d75daa1cc
commit 62b8a0c823
3 changed files with 20 additions and 20 deletions

View file

@ -38,7 +38,7 @@ export default class GitHubSyncPlugin extends Plugin {
);
await this.syncManager.loadMetadata();
if (this.settings.uploadStrategy == "interval") {
if (this.settings.syncStrategy == "interval") {
this.restartSyncInterval();
}
@ -178,7 +178,7 @@ export default class GitHubSyncPlugin extends Plugin {
// when settings are changed
startSyncInterval() {
const intervalID = this.syncManager.startSyncInterval(
this.settings.uploadInterval,
this.settings.syncInterval,
);
this.registerInterval(intervalID);
}
@ -189,6 +189,6 @@ export default class GitHubSyncPlugin extends Plugin {
restartSyncInterval() {
this.syncManager.stopSyncInterval();
this.syncManager.startSyncInterval(this.settings.uploadInterval);
this.syncManager.startSyncInterval(this.settings.syncInterval);
}
}

View file

@ -6,8 +6,8 @@ export interface GitHubSyncSettings {
githubBranch: string;
repoContentDir: string;
localContentDir: string;
uploadStrategy: "manual" | "interval";
uploadInterval: number;
syncStrategy: "manual" | "interval";
syncInterval: number;
syncOnStartup: boolean;
conflictHandling: "ignore" | "ask" | "overwrite";
showStatusBarItem: boolean;
@ -22,8 +22,8 @@ export const DEFAULT_SETTINGS: GitHubSyncSettings = {
githubBranch: "main",
repoContentDir: "",
localContentDir: "",
uploadStrategy: "manual",
uploadInterval: 1,
syncStrategy: "manual",
syncInterval: 1,
syncOnStartup: false,
conflictHandling: "ask",
showStatusBarItem: true,

View file

@ -123,43 +123,43 @@ export default class GitHubSyncSettingsTab extends PluginSettingTab {
containerEl.createEl("h2", { text: "Sync" });
const uploadStrategies = {
const syncStrategies = {
manual: "Manually",
interval: "On Interval",
};
const uploadStrategySetting = new Setting(containerEl)
.setName("Upload strategy")
.setDesc("When to upload local files to remote repository");
.setName("Sync strategy")
.setDesc("How to sync files with remote repository");
let syncInterval = "1";
if (this.plugin.settings.uploadInterval) {
syncInterval = this.plugin.settings.uploadInterval.toString();
if (this.plugin.settings.syncInterval) {
syncInterval = this.plugin.settings.syncInterval.toString();
}
const intervalSettings = new Setting(containerEl)
.setName("Upload interval")
.setDesc("Upload interval in minutes between automatic uploads")
.setName("Sync interval")
.setDesc("Interval in minutes between automatic syncs")
.addText((text) =>
text
.setPlaceholder("Interval in minutes")
.setValue(syncInterval)
.onChange(async (value) => {
this.plugin.settings.uploadInterval = parseInt(value) || 1;
this.plugin.settings.syncInterval = parseInt(value) || 1;
await this.plugin.saveSettings();
// We need to restart the interval if the value is changed
this.plugin.restartSyncInterval();
}),
);
intervalSettings.setDisabled(
this.plugin.settings.uploadStrategy !== "interval",
this.plugin.settings.syncStrategy !== "interval",
);
uploadStrategySetting.addDropdown((dropdown) =>
dropdown
.addOptions(uploadStrategies)
.setValue(this.plugin.settings.uploadStrategy)
.onChange(async (value: keyof typeof uploadStrategies) => {
.addOptions(syncStrategies)
.setValue(this.plugin.settings.syncStrategy)
.onChange(async (value: keyof typeof syncStrategies) => {
intervalSettings.setDisabled(value !== "interval");
this.plugin.settings.uploadStrategy = value;
this.plugin.settings.syncStrategy = value;
await this.plugin.saveSettings();
if (value === "interval") {
this.plugin.startSyncInterval();