mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-23 07:51:18 +01:00
Squish the last bugs
This commit is contained in:
parent
9fbcb12210
commit
15bc0e4dba
@ -20,7 +20,7 @@ function getExtensionActionCallback(action) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const reload = isTrueBoolean(args?.reload);
|
const reload = !isFalseBoolean(args?.reload);
|
||||||
const internalExtensionName = findExtension(extensionName);
|
const internalExtensionName = findExtension(extensionName);
|
||||||
if (!internalExtensionName) {
|
if (!internalExtensionName) {
|
||||||
toastr.warning(`Extension ${extensionName} does not exist.`);
|
toastr.warning(`Extension ${extensionName} does not exist.`);
|
||||||
@ -43,7 +43,14 @@ function getExtensionActionCallback(action) {
|
|||||||
action = isEnabled ? 'disable' : 'enable';
|
action = isEnabled ? 'disable' : 'enable';
|
||||||
}
|
}
|
||||||
|
|
||||||
reload && toastr.info(`${action.charAt(0).toUpperCase() + action.slice(1)}ing extension ${extensionName} and reloading...`);
|
if (reload) {
|
||||||
|
toastr.info(`${action.charAt(0).toUpperCase() + action.slice(1)}ing extension ${extensionName} and reloading...`);
|
||||||
|
|
||||||
|
// Clear input, so it doesn't stay because the command didn't "finish",
|
||||||
|
// and wait for a bit to both show the toast and let the clear bubble through.
|
||||||
|
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
}
|
||||||
|
|
||||||
if (action === 'enable') {
|
if (action === 'enable') {
|
||||||
await enableExtension(internalExtensionName, reload);
|
await enableExtension(internalExtensionName, reload);
|
||||||
@ -53,6 +60,12 @@ function getExtensionActionCallback(action) {
|
|||||||
|
|
||||||
toastr.success(`Extension ${extensionName} ${action}d.`);
|
toastr.success(`Extension ${extensionName} ${action}d.`);
|
||||||
|
|
||||||
|
|
||||||
|
console.info(`Extension ${action}ed: ${extensionName}`);
|
||||||
|
if (!reload) {
|
||||||
|
console.info('Reload not requested, so page needs to be reloaded manually for changes to take effect.');
|
||||||
|
}
|
||||||
|
|
||||||
return internalExtensionName;
|
return internalExtensionName;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -88,6 +101,7 @@ export function registerExtensionSlashCommands() {
|
|||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'extension-enable',
|
name: 'extension-enable',
|
||||||
callback: getExtensionActionCallback('enable'),
|
callback: getExtensionActionCallback('enable'),
|
||||||
|
returns: 'The internal extension name',
|
||||||
namedArgumentList: [
|
namedArgumentList: [
|
||||||
SlashCommandNamedArgument.fromProps({
|
SlashCommandNamedArgument.fromProps({
|
||||||
name: 'reload',
|
name: 'reload',
|
||||||
@ -127,7 +141,8 @@ export function registerExtensionSlashCommands() {
|
|||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'extension-disable',
|
name: 'extension-disable',
|
||||||
callback: getExtensionActionCallback('enable'),
|
callback: getExtensionActionCallback('disable'),
|
||||||
|
returns: 'The internal extension name',
|
||||||
namedArgumentList: [
|
namedArgumentList: [
|
||||||
SlashCommandNamedArgument.fromProps({
|
SlashCommandNamedArgument.fromProps({
|
||||||
name: 'reload',
|
name: 'reload',
|
||||||
@ -177,6 +192,7 @@ export function registerExtensionSlashCommands() {
|
|||||||
|
|
||||||
return await getExtensionActionCallback(action)(args, extensionName);
|
return await getExtensionActionCallback(action)(args, extensionName);
|
||||||
},
|
},
|
||||||
|
returns: 'The internal extension name',
|
||||||
namedArgumentList: [
|
namedArgumentList: [
|
||||||
SlashCommandNamedArgument.fromProps({
|
SlashCommandNamedArgument.fromProps({
|
||||||
name: 'reload',
|
name: 'reload',
|
||||||
@ -236,6 +252,7 @@ export function registerExtensionSlashCommands() {
|
|||||||
const isEnabled = !extension_settings.disabledExtensions.includes(internalExtensionName);
|
const isEnabled = !extension_settings.disabledExtensions.includes(internalExtensionName);
|
||||||
return String(isEnabled);
|
return String(isEnabled);
|
||||||
},
|
},
|
||||||
|
returns: '<code>true</code>/<code>false</code> - The state of the extension, whether it is enabled.',
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
SlashCommandArgument.fromProps({
|
SlashCommandArgument.fromProps({
|
||||||
description: 'Extension name',
|
description: 'Extension name',
|
||||||
@ -267,6 +284,7 @@ export function registerExtensionSlashCommands() {
|
|||||||
const exists = findExtension(extensionName) !== undefined;
|
const exists = findExtension(extensionName) !== undefined;
|
||||||
return exists ? 'true' : 'false';
|
return exists ? 'true' : 'false';
|
||||||
},
|
},
|
||||||
|
returns: '<code>true</code>/<code>false</code> - Whether the extension exists and is installed.',
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
SlashCommandArgument.fromProps({
|
SlashCommandArgument.fromProps({
|
||||||
description: 'Extension name',
|
description: 'Extension name',
|
||||||
|
Loading…
Reference in New Issue
Block a user