Skip to content

Node.js based forum software built for the modern web

fix: update modal to stay open on handle registration

Julian Lam423e9d9d63aa
diff --git a/public/language/en-GB/intents.json b/public/language/en-GB/intents.json
index 114797c91f..cff9c83f59 100644
--- a/public/language/en-GB/intents.json
+++ b/public/language/en-GB/intents.json
@@ -7,7 +7,6 @@
"registered-handles": "Registered Handles",
"no-handles": "No handles registered yet.",
"intents-label": "Supported Intents",
- "register-success": "Handle registered successfully!",
"register-error": "Failed to register handle. Please check the handle format and try again.",
"invalid-handle": "Please enter a valid handle in the format @[email protected]"
}
diff --git a/public/src/modules/intents.js b/public/src/modules/intents.js
index 316b926b0a..81d68f8a2c 100644
--- a/public/src/modules/intents.js
+++ b/public/src/modules/intents.js
@@ -78,8 +78,8 @@ export async function refresh(handle) {
}
export function register() {
- const map = list();
- const handles = Array.from(map.entries()).map(([handle, intents]) => ({ handle, intents }));
+ let map = list();
+ let handles = Array.from(map.entries()).map(([handle, intents]) => ({ handle, intents }));
app.parseAndTranslate('modals/intents/register', {
description: '[[intents:description]]',
@@ -114,18 +114,15 @@ export function register() {
submitBtn.prop('disabled', true).text('[[global:loading]]');
try {
- const result = await refresh(handle);
- if (result) {
- modal.modal('hide');
- alerts.success('[[intents:register-success]]');
- require(['hooks'], (hooks) => {
- hooks.fire('action:intents.registered', { handle, intents: result.intents });
- });
- }
+ await refresh(handle);
+ map = list();
+ handles = Array.from(map.entries()).map(([handle, intents]) => ({ handle, intents }));
+ const html = await app.parseAndTranslate('modals/intents/register', 'handles', { handles });
+ modal.find('#intents-registered-list').html(html);
} catch (e) {
alerts.error('[[intents:register-error]]');
} finally {
- submitBtn.prop('disabled', false).text('[[intents:register-button]]');
+ submitBtn.prop('disabled', false);
}
});