mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-13 18:07:20 +01:00
fix for loading old QRs
This commit is contained in:
parent
de5452c48d
commit
30757dc92e
@ -83,16 +83,14 @@ const loadSets = async () => {
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const setList = (await response.json()).quickReplyPresets ?? [];
|
const setList = (await response.json()).quickReplyPresets ?? [];
|
||||||
for (const set of setList) {
|
for (const set of setList) {
|
||||||
if (set.version == 2) {
|
if (set.version !== 2) {
|
||||||
QuickReplySet.list.push(QuickReplySet.from(JSON.parse(JSON.stringify(set))));
|
// migrate old QR set
|
||||||
} else {
|
set.version = 2;
|
||||||
const qrs = new QuickReplySet();
|
set.disableSend = set.quickActionEnabled ?? false;
|
||||||
qrs.name = set.name;
|
set.placeBeforeInput = set.placeBeforeInputEnabled ?? false;
|
||||||
qrs.disableSend = set.quickActionEnabled ?? false;
|
set.injectInput = set.AutoInputInject ?? false;
|
||||||
qrs.placeBeforeInput = set.placeBeforeInputEnabled ?? false;
|
set.qrList = set.quickReplySlots.map((slot,idx)=>{
|
||||||
qrs.injectInput = set.AutoInputInject ?? false;
|
const qr = {};
|
||||||
qrs.qrList = set.quickReplySlots.map((slot,idx)=>{
|
|
||||||
const qr = new QuickReply();
|
|
||||||
qr.id = idx + 1;
|
qr.id = idx + 1;
|
||||||
qr.label = slot.label;
|
qr.label = slot.label;
|
||||||
qr.title = slot.title;
|
qr.title = slot.title;
|
||||||
@ -102,16 +100,18 @@ const loadSets = async () => {
|
|||||||
qr.executeOnUser = slot.autoExecute_userMessage ?? false;
|
qr.executeOnUser = slot.autoExecute_userMessage ?? false;
|
||||||
qr.executeOnAi = slot.autoExecute_botMessage ?? false;
|
qr.executeOnAi = slot.autoExecute_botMessage ?? false;
|
||||||
qr.executeOnChatChange = slot.autoExecute_chatLoad ?? false;
|
qr.executeOnChatChange = slot.autoExecute_chatLoad ?? false;
|
||||||
qr.contextList = (slot.contextMenu ?? []).map(it=>(QuickReplyContextLink.from({
|
qr.contextList = (slot.contextMenu ?? []).map(it=>({
|
||||||
set: it.preset,
|
set: it.preset,
|
||||||
isChained: it.chain,
|
isChained: it.chain,
|
||||||
})));
|
}));
|
||||||
return qr;
|
return qr;
|
||||||
});
|
});
|
||||||
QuickReplySet.list.push(qrs);
|
}
|
||||||
await qrs.save();
|
if (set.version == 2) {
|
||||||
|
QuickReplySet.list.push(QuickReplySet.from(JSON.parse(JSON.stringify(set))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// need to load QR lists after all sets are loaded to be able to resolve context menu entries
|
||||||
setList.forEach((set, idx)=>{
|
setList.forEach((set, idx)=>{
|
||||||
QuickReplySet.list[idx].qrList = set.qrList.map(it=>QuickReply.from(it));
|
QuickReplySet.list[idx].qrList = set.qrList.map(it=>QuickReply.from(it));
|
||||||
QuickReplySet.list[idx].init();
|
QuickReplySet.list[idx].init();
|
||||||
|
Loading…
Reference in New Issue
Block a user