mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
move silencing of loud /aborts into execute function when handled
This commit is contained in:
@ -2834,6 +2834,7 @@ async function executeSlashCommandsWithOptions(text, options = {}) {
|
|||||||
const result = await closure.execute();
|
const result = await closure.execute();
|
||||||
if (result.isAborted && !result.isQuietlyAborted) {
|
if (result.isAborted && !result.isQuietlyAborted) {
|
||||||
toastr.warning(result.abortReason, 'Command execution aborted');
|
toastr.warning(result.abortReason, 'Command execution aborted');
|
||||||
|
closure.abortController.signal.isQuiet = true;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -342,17 +342,10 @@ async function whileCallback(args, value) {
|
|||||||
if (result && command) {
|
if (result && command) {
|
||||||
if (command instanceof SlashCommandClosure) {
|
if (command instanceof SlashCommandClosure) {
|
||||||
commandResult = await command.execute();
|
commandResult = await command.execute();
|
||||||
// don't suppress potentially loud /abort (need to bubble up to executeSlashCommandsWithOptions for toast)
|
|
||||||
if (commandResult.isAborted) break;
|
|
||||||
} else {
|
} else {
|
||||||
commandResult = await executeSubCommands(command, args._scope, args._parserFlags, args._abortController);
|
commandResult = await executeSubCommands(command, args._scope, args._parserFlags, args._abortController);
|
||||||
if (commandResult.isAborted) {
|
|
||||||
// abort toast (if loud) is already shown in subcommand execution,
|
|
||||||
// overwrite signal to quiet to prevent second toast from ancestor executions
|
|
||||||
args._abortController.signal.isQuiet = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (commandResult.isAborted) break;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -393,18 +386,11 @@ async function timesCallback(args, value) {
|
|||||||
if (command instanceof SlashCommandClosure) {
|
if (command instanceof SlashCommandClosure) {
|
||||||
command.scope.setMacro('timesIndex', i);
|
command.scope.setMacro('timesIndex', i);
|
||||||
result = await command.execute();
|
result = await command.execute();
|
||||||
// don't suppress potentially loud /abort (need to bubble up to executeSlashCommandsWithOptions for toast)
|
|
||||||
if (result.isAborted) break;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = await executeSubCommands(command.replace(/\{\{timesIndex\}\}/g, i.toString()), args._scope, args._parserFlags, args._abortController);
|
result = await executeSubCommands(command.replace(/\{\{timesIndex\}\}/g, i.toString()), args._scope, args._parserFlags, args._abortController);
|
||||||
if (result.isAborted) {
|
|
||||||
// abort toast (if loud) is already shown in subcommand execution,
|
|
||||||
// overwrite signal to quiet to prevent second toast from ancestor executions
|
|
||||||
args._abortController.signal.isQuiet = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (result.isAborted) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result?.pipe ?? '';
|
return result?.pipe ?? '';
|
||||||
@ -438,13 +424,7 @@ async function ifCallback(args, value) {
|
|||||||
commandResult = await executeSubCommands(args.else, args._scope, args._parserFlags, args._abortController);
|
commandResult = await executeSubCommands(args.else, args._scope, args._parserFlags, args._abortController);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is only reached by subcommands, not by closures, so this is fine
|
|
||||||
if (commandResult) {
|
if (commandResult) {
|
||||||
if (commandResult.isAborted) {
|
|
||||||
// abort toast (if loud) is already shown in subcommand execution,
|
|
||||||
// overwrite signal to quiet to prevent second toast from ancestor executions
|
|
||||||
args._abortController.signal.isQuiet = true;
|
|
||||||
}
|
|
||||||
return commandResult.pipe;
|
return commandResult.pipe;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
Reference in New Issue
Block a user