mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
don't try to parse empty qrJson on add from text
This commit is contained in:
@@ -241,22 +241,26 @@ export class QuickReplySet {
|
|||||||
}
|
}
|
||||||
addQuickReplyFromText(qrJson) {
|
addQuickReplyFromText(qrJson) {
|
||||||
let data;
|
let data;
|
||||||
try {
|
if (qrJson) {
|
||||||
data = JSON.parse(qrJson ?? '{}');
|
try {
|
||||||
delete data.id;
|
data = JSON.parse(qrJson ?? '{}');
|
||||||
} catch {
|
delete data.id;
|
||||||
// not JSON data
|
} catch {
|
||||||
}
|
// not JSON data
|
||||||
if (data) {
|
}
|
||||||
// JSON data
|
if (data) {
|
||||||
if (data.label === undefined || data.message === undefined) {
|
// JSON data
|
||||||
// not a QR
|
if (data.label === undefined || data.message === undefined) {
|
||||||
toastr.error('Not a QR.');
|
// not a QR
|
||||||
return;
|
toastr.error('Not a QR.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no JSON, use plaintext as QR message
|
||||||
|
data = { message: qrJson };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no JSON, use plaintext as QR message
|
data = {};
|
||||||
data = { message: qrJson };
|
|
||||||
}
|
}
|
||||||
const newQr = this.addQuickReply(data);
|
const newQr = this.addQuickReply(data);
|
||||||
return newQr;
|
return newQr;
|
||||||
|
Reference in New Issue
Block a user