Fix duplicateQrSet

Fixes #4364
This commit is contained in:
Cohee
2025-08-10 16:10:41 +03:00
parent 5366175109
commit c8b02dfd68
2 changed files with 7 additions and 3 deletions
@@ -9,6 +9,10 @@ import { QuickReply } from './QuickReply.js';
export class QuickReplySet {
/**@type {QuickReplySet[]}*/ static list = [];
/**
* @param {Partial<QuickReplySet>} props
* @returns {QuickReplySet}
*/
static from(props) {
props.qrList = []; //props.qrList?.map(it=>QuickReply.from(it));
const instance = Object.assign(new this(), props);
@@ -470,10 +470,10 @@ export class SettingsUi {
toastr.error(`A Quick Reply Set named "${newName}" already exists.`);
return;
}
const newQrSet = QuickReplySet.from(JSON.parse(JSON.stringify(this.currentQrSet)));
const newQrSet = QuickReplySet.from(this.currentQrSet.toJSON());
newQrSet.name = newName;
newQrSet.qrList = this.currentQrSet.qrList.map(qr => QuickReply.from(JSON.parse(JSON.stringify(qr))));
newQrSet.addQuickReply();
newQrSet.qrList = this.currentQrSet.qrList.map(qr => QuickReply.from(qr.toJSON()));
newQrSet.init();
const idx = QuickReplySet.list.findIndex(it => it.name.toLowerCase().localeCompare(newName.toLowerCase()) == 1);
if (idx > -1) {
QuickReplySet.list.splice(idx, 0, newQrSet);