Squish the last bugs

15bc0e4dba7ffd8ad250061b765424e838bf3099

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +21 -3Ignore whitespace
public/scripts/extensions-slashcommands.js+21 -3
@@ -20,7 +20,7 @@ function getExtensionActionCallback(action) {
2020 return '';
2121 }
2222
2323 const reload = isTrueBoolean!isFalseBoolean(args?.reload);
2424 const internalExtensionName = findExtension(extensionName);
2525 if (!internalExtensionName) {
2626 toastr.warning(`Extension ${extensionName} does not exist.`);
@@ -43,7 +43,14 @@ function getExtensionActionCallback(action) {
4343 action = isEnabled ? 'disable' : 'enable';
4444 }
4545
46- reload && toastr.info(`${action.charAt(0).toUpperCase() + action.slice(1)}ing extension ${extensionName} and reloading...`);
46+ if (reload) {
47+ toastr.info(`${action.charAt(0).toUpperCase() + action.slice(1)}ing extension ${extensionName} and reloading...`);
48+
49+ // Clear input, so it doesn't stay because the command didn't "finish",
50+ // and wait for a bit to both show the toast and let the clear bubble through.
51+ $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
52+ await new Promise(resolve => setTimeout(resolve, 100));
53+ }
4754
4855 if (action === 'enable') {
4956 await enableExtension(internalExtensionName, reload);
@@ -53,6 +60,12 @@ function getExtensionActionCallback(action) {
5360
5461 toastr.success(`Extension ${extensionName} ${action}d.`);
5562
63+
64+ console.info(`Extension ${action}ed: ${extensionName}`);
65+ if (!reload) {
66+ console.info('Reload not requested, so page needs to be reloaded manually for changes to take effect.');
67+ }
68+
5669 return internalExtensionName;
5770 };
5871}
@@ -88,6 +101,7 @@ export function registerExtensionSlashCommands() {
88101 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
89102 name: 'extension-enable',
90103 callback: getExtensionActionCallback('enable'),
104+ returns: 'The internal extension name',
91105 namedArgumentList: [
92106 SlashCommandNamedArgument.fromProps({
93107 name: 'reload',
@@ -127,7 +141,8 @@ export function registerExtensionSlashCommands() {
127141 }));
128142 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
129143 name: 'extension-disable',
130144 callback: getExtensionActionCallback('enabledisable'),
145+ returns: 'The internal extension name',
131146 namedArgumentList: [
132147 SlashCommandNamedArgument.fromProps({
133148 name: 'reload',
@@ -177,6 +192,7 @@ export function registerExtensionSlashCommands() {
177192
178193 return await getExtensionActionCallback(action)(args, extensionName);
179194 },
195+ returns: 'The internal extension name',
180196 namedArgumentList: [
181197 SlashCommandNamedArgument.fromProps({
182198 name: 'reload',
@@ -236,6 +252,7 @@ export function registerExtensionSlashCommands() {
236252 const isEnabled = !extension_settings.disabledExtensions.includes(internalExtensionName);
237253 return String(isEnabled);
238254 },
255+ returns: '<code>true</code>/<code>false</code> - The state of the extension, whether it is enabled.',
239256 unnamedArgumentList: [
240257 SlashCommandArgument.fromProps({
241258 description: 'Extension name',
@@ -267,6 +284,7 @@ export function registerExtensionSlashCommands() {
267284 const exists = findExtension(extensionName) !== undefined;
268285 return exists ? 'true' : 'false';
269286 },
287+ returns: '<code>true</code>/<code>false</code> - Whether the extension exists and is installed.',
270288 unnamedArgumentList: [
271289 SlashCommandArgument.fromProps({
272290 description: 'Extension name',