| 303 | 304 | this.settings.save(); |
| 304 | 305 | } |
| 305 | 306 | |
| 307 | + async renameQrSet() { |
| 308 | + const newName = await callPopup('Enter new name for the Quick Reply Set:', 'input'); |
| 309 | + if (newName && newName.length > 0) { |
| 310 | + const existingSet = QuickReplySet.get(newName); |
| 311 | + if (existingSet) { |
| 312 | + toastr.error(`A Quick Reply Set named "${newName}" already exists.`); |
| 313 | + return; |
| 314 | + } |
| 315 | + const oldName = this.currentQrSet.name; |
| 316 | + this.currentQrSet.name = newName; |
| 317 | + await this.currentQrSet.save(); |
| 318 | + |
| 319 | + // Update the option in all select dropdowns |
| 320 | + /** @type {NodeListOf<HTMLOptionElement>} */ |
| 321 | + const options = this.dom.querySelectorAll(`#qr--set option[value="${oldName}"], select.qr--set option[value="${oldName}"]`); |
| 322 | + options.forEach(option => { |
| 323 | + option.value = newName; |
| 324 | + option.textContent = newName; |
| 325 | + }); |
| 326 | + |
| 327 | + // Update in in both set lists |
| 328 | + this.settings.config.setList.forEach(set => { |
| 329 | + if (set.set.name === oldName) { |
| 330 | + set.set.name = newName; |
| 331 | + } |
| 332 | + }); |
| 333 | + this.settings.chatConfig?.setList.forEach(set => { |
| 334 | + if (set.set.name === oldName) { |
| 335 | + set.set.name = newName; |
| 336 | + } |
| 337 | + }); |
| 338 | + |
| 339 | + this.settings.save(); |
| 340 | + this.currentSet.value = newName; |
| 341 | + console.info(`Quick Reply Set renamed from ""${oldName}" to "${newName}".`); |
| 342 | + } |
| 343 | + } |
| 344 | + |
| 306 | 345 | async addQrSet() { |
| 307 | 346 | const name = await callPopup('Quick Reply Set Name:', 'input'); |
| 308 | 347 | if (name && name.length > 0) { |