mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-03 03:17:54 +01:00
Still fighting /ask corruptions #2832
This commit is contained in:
parent
4e67cc1bc4
commit
6a3b226da2
@ -2525,6 +2525,10 @@ async function askCharacter(args, text) {
|
|||||||
setCharacterName(character.name);
|
setCharacterName(character.name);
|
||||||
|
|
||||||
const restoreCharacter = () => {
|
const restoreCharacter = () => {
|
||||||
|
if (String(this_chid) !== String(chId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setCharacterId(prevChId);
|
setCharacterId(prevChId);
|
||||||
setCharacterName(characters[prevChId].name);
|
setCharacterName(characters[prevChId].name);
|
||||||
|
|
||||||
@ -2541,14 +2545,14 @@ async function askCharacter(args, text) {
|
|||||||
|
|
||||||
// Run generate and restore previous character
|
// Run generate and restore previous character
|
||||||
try {
|
try {
|
||||||
|
eventSource.once(event_types.MESSAGE_RECEIVED, restoreCharacter);
|
||||||
toastr.info(`Asking ${character.name} something...`);
|
toastr.info(`Asking ${character.name} something...`);
|
||||||
askResult = await Generate('ask_command');
|
askResult = await Generate('ask_command');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
restoreCharacter();
|
||||||
console.error('Error running /ask command', error);
|
console.error('Error running /ask command', error);
|
||||||
} finally {
|
} finally {
|
||||||
restoreCharacter();
|
if (String(this_chid) === String(prevChId)) {
|
||||||
|
|
||||||
if (this_chid === prevChId) {
|
|
||||||
await saveChatConditional();
|
await saveChatConditional();
|
||||||
} else {
|
} else {
|
||||||
toastr.error('It is strongly recommended to reload the page.', 'Something went wrong');
|
toastr.error('It is strongly recommended to reload the page.', 'Something went wrong');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user