Make some settings name clearer

This commit is contained in:
Silvano Cerza 2025-01-11 16:00:48 +01:00
parent 81b7f2b235
commit 88d2baa901
3 changed files with 22 additions and 22 deletions

View file

@ -101,7 +101,7 @@ export default class GitHubSyncPlugin extends Plugin {
this.syncIntervalId = window.setInterval( this.syncIntervalId = window.setInterval(
() => this.uploadModifiedFiles(), () => this.uploadModifiedFiles(),
// Sync interval is set in minutes but setInterval expects milliseconds // Sync interval is set in minutes but setInterval expects milliseconds
this.settings.syncInterval * 60 * 1000, this.settings.uploadInterval * 60 * 1000,
); );
this.registerInterval(this.syncIntervalId); this.registerInterval(this.syncIntervalId);
} }
@ -176,7 +176,7 @@ export default class GitHubSyncPlugin extends Plugin {
this.settings.githubRepo, this.settings.githubRepo,
this.settings.githubBranch, this.settings.githubBranch,
); );
if (this.settings.syncStrategy == "interval") { if (this.settings.uploadStrategy == "interval") {
this.restartSyncInterval(); this.restartSyncInterval();
} }
} }

View file

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

View file

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