diff --git a/src/Settings/SettingsManager.ts b/src/Settings/SettingsManager.ts index 83423f90..c2ad39ef 100644 --- a/src/Settings/SettingsManager.ts +++ b/src/Settings/SettingsManager.ts @@ -18,7 +18,7 @@ export class SettingsManager { public async addToolbar(toolbar: ToolbarSettings): Promise { this.plugin.settings.toolbars.push(toolbar); this.plugin.settings.toolbars.sort((a, b) => a.name.localeCompare(b.name)); - await this.plugin.settingsManager.save(); + await this.save(); } /** @@ -59,7 +59,7 @@ export class SettingsManager { * @param item ToolbarItemSettings to duplicate. * @returns string UUID of the new item. */ - public duplicateToolbarItem(toolbar: ToolbarSettings, item: ToolbarItemSettings, insertAfter: boolean = false): string { + public async duplicateToolbarItem(toolbar: ToolbarSettings, item: ToolbarItemSettings, insertAfter: boolean = false): Promise { debugLog('duplicateToolbarItem', item); let newItem = JSON.parse(JSON.stringify(item)) as ToolbarItemSettings; newItem.uuid = getUUID(); diff --git a/src/Settings/UI/Modals/ToolbarSettingsModal.ts b/src/Settings/UI/Modals/ToolbarSettingsModal.ts index 4f1fd567..3f5da3e0 100644 --- a/src/Settings/UI/Modals/ToolbarSettingsModal.ts +++ b/src/Settings/UI/Modals/ToolbarSettingsModal.ts @@ -498,6 +498,7 @@ export default class ToolbarSettingsModal extends Modal { const modifierPressed = (Platform.isWin || Platform.isLinux) ? e?.ctrlKey : e?.metaKey; if (modifierPressed) { const newItemUuid = this.plugin.settingsManager.duplicateToolbarItem(this.toolbar, toolbarItem, true); + this.plugin.settingsManager.save(); this.display(`.note-toolbar-sortablejs-list > div[${SettingsAttr.ItemUuid}="${newItemUuid}"] > .note-toolbar-setting-item-preview-container > .note-toolbar-setting-item-preview`); } break; @@ -683,8 +684,9 @@ export default class ToolbarSettingsModal extends Modal { button .setIcon('copy-plus') .setTooltip(t('setting.item.button-duplicate-tooltip')) - .onClick(() => { + .onClick(async () => { const newItemUuid = this.plugin.settingsManager.duplicateToolbarItem(this.toolbar, toolbarItem, true); + await this.plugin.settingsManager.save(); this.display(`.note-toolbar-sortablejs-list > div[${SettingsAttr.ItemUuid}="${newItemUuid}"] > .note-toolbar-setting-item-preview-container > .note-toolbar-setting-item-preview`); }); })