Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update settings grammar #656

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/setting/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "src/lineAuthor/model";
import ObsidianGit from "src/main";
import { ObsidianGitSettings, SyncMethod } from "src/types";
import { convertToRgb, rgbToString } from "src/utils";
import { convertToRgb, rgbToString, formatMinutes } from "src/utils";

const FORMAT_STRING_REFERENCE_URL =
"https://momentjs.com/docs/#/parsing/string-format/";
Expand Down Expand Up @@ -110,7 +110,9 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
plugin.settings.autoSaveInterval
);
new Notice(
`Automatic ${commitOrBackup} enabled! Every ${plugin.settings.autoSaveInterval} minutes.`
`Automatic ${commitOrBackup} enabled! Every ${formatMinutes(
plugin.settings.autoSaveInterval
)}.`
);
} else if (
plugin.settings.autoSaveInterval <= 0
Expand All @@ -128,9 +130,13 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {

if (!plugin.settings.setLastSaveToLastCommit)
new Setting(containerEl)
.setName(`Auto Backup after stop editing any file`)
.setName(`Auto Backup after stopping file edits`)
.setDesc(
`Requires the ${commitOrBackup} interval not to be 0. If turned on, do auto ${commitOrBackup} every ${plugin.settings.autoSaveInterval} minutes after stop editing any file. This also prevents auto ${commitOrBackup} while editing a file. If turned off, it's independent from the last change.`
`Requires the ${commitOrBackup} interval not to be 0.
If turned on, do auto ${commitOrBackup} every ${formatMinutes(
plugin.settings.autoSaveInterval
)} after stopping file edits.
This also prevents auto ${commitOrBackup} while editing a file. If turned off, it's independent from the last change.`
)
.addToggle((toggle) =>
toggle
Expand Down Expand Up @@ -188,7 +194,9 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
plugin.settings.autoPushInterval
);
new Notice(
`Automatic push enabled! Every ${plugin.settings.autoPushInterval} minutes.`
`Automatic push enabled! Every ${formatMinutes(
plugin.settings.autoPushInterval
)}.`
);
} else if (
plugin.settings.autoPushInterval <= 0
Expand Down Expand Up @@ -227,7 +235,9 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
plugin.settings.autoPullInterval
);
new Notice(
`Automatic pull enabled! Every ${plugin.settings.autoPullInterval} minutes.`
`Automatic pull enabled! Every ${formatMinutes(
plugin.settings.autoPullInterval
)}.`
);
} else if (
plugin.settings.autoPullInterval <= 0
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ export function getDisplayPath(path: string): string {
if (path.endsWith("/")) return path;
return path.split("/").last()!.replace(".md", "");
}

export function formatMinutes(minutes: number): string {
if (minutes === 1) return "1 minute";
return `${minutes} minutes`;
}
Loading