From 3a9b163aca791a9c8d54abcbf39b8a08c5904efd Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Wed, 20 Dec 2023 18:05:14 +0000 Subject: [PATCH] add delete hack :( --- public/scripts/extensions/quick-reply/index.js | 1 - .../extensions/quick-reply/src/ui/SettingsUi.js | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js index 08ff88949..a06be2737 100644 --- a/public/scripts/extensions/quick-reply/index.js +++ b/public/scripts/extensions/quick-reply/index.js @@ -15,7 +15,6 @@ import { SettingsUi } from './src/ui/SettingsUi.js'; //TODO context menus //TODO move advanced QR options into own UI class //TODO slash commands -//TODO delete QR set //TODO handle replacing QR set (create->overwrite): update configs that use this set //TODO easy way to CRUD QRs and sets //TODO easy way to set global and chat sets diff --git a/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js b/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js index 1a31a6762..376e29879 100644 --- a/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js +++ b/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js @@ -211,6 +211,20 @@ export class SettingsUi { const confirmed = await callPopup(`Are you sure you want to delete the Quick Reply Set "${this.currentQrSet.name}"? This cannot be undone.`, 'confirm'); if (confirmed) { await this.currentQrSet.delete(); + //HACK should just bubble up from QuickReplySet.delete() but that would require proper or at least more comples onDelete listeners + for (let i = this.settings.config.setList.length - 1; i >= 0; i--) { + if (this.settings.config.setList[i].set == this.currentQrSet) { + this.settings.config.setList.splice(i, 1); + } + } + if (this.settings.chatConfig) { + for (let i = this.settings.chatConfig.setList.length - 1; i >= 0; i--) { + if (this.settings.config.setList[i].set == this.currentQrSet) { + this.settings.config.setList.splice(i, 1); + } + } + } + this.settings.save(); this.rerender(); } }