refactor: use Notice instead of Setting.setDesc

This commit is contained in:
kotaindah55 2025-02-05 17:20:35 +02:00
parent 6cc89e67e5
commit 1a7828e5ca
2 changed files with 6 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import { configureDelimLookup } from "src/utils";
export default class ExtendedMarkdownSyntax extends Plugin {
settings: PluginSettings;
areSettingsChanged: boolean = false;
async onload() {
await this.loadSettings();
this.addSettingTab(new SettingTab(this.app, this));
@ -29,6 +30,10 @@ export default class ExtendedMarkdownSyntax extends Plugin {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
if (!this.areSettingsChanged) {
this.areSettingsChanged = true;
new Notice("You must restart the app to take the effect")
}
await this.saveData(this.settings);
}
onunload(): void {

View file

@ -18,6 +18,7 @@ export class SettingTab extends PluginSettingTab {
display(): void {
let { containerEl } = this,
{ settings } = this.plugin;
this.plugin.areSettingsChanged = false;
containerEl.empty();
new Setting(containerEl)
.setName("Insertion (underline)")
@ -81,8 +82,5 @@ export class SettingTab extends PluginSettingTab {
toggle.setValue(settings.colorButton);
toggle.onChange((val) => { settings.colorButton = val; this.plugin.saveSettings() });
});
new Setting(containerEl)
.setDesc("You must restart the app to take the effect.")
.descEl.addClass("warning-desc");
}
}