Skip to content

Node.js based forum software built for the modern web

fix: unworking code from an errant AI refactor

Julian Lam8fa6987a189f
diff --git a/public/language/en-US/intents.json b/public/language/en-US/intents.json
index 4e5e92b113..6135bffac1 100644
--- a/public/language/en-US/intents.json
+++ b/public/language/en-US/intents.json
@@ -1,4 +1,9 @@
{
+ "display.create": "Create & Reply",
+ "display.like": "Upvote",
+ "display.dislike": "Downvote",
+ "display.follow": "Follow",
+ "display.object": "View",
"title": "Register Open Social Web Handle",
"description": "Enter your Open Social Web handle to register for Activity Intents. This will allow you to share content from this forum to your social profile.",
"handle-label": "Open Social Web Handle",
diff --git a/public/src/modules/intents.js b/public/src/modules/intents.js
index 61190276ab..bfeb764565 100644
--- a/public/src/modules/intents.js
+++ b/public/src/modules/intents.js
@@ -3,7 +3,7 @@
import { dialog } from 'bootbox';
import { get } from 'api';
import storage from 'storage';
-import { translateKeys } from 'translator';
+import { translate, translateKeys } from 'translator';
import * as alerts from './alerts';
@@ -93,8 +93,8 @@ export async function refresh(handle) {
}
export async function register() {
- const map = list();
- const handles = await Promise.all(Array.from(map.entries()).map(async ([handle, intents]) => ({
+ let map = list();
+ let handles = await Promise.all(Array.from(map.entries()).map(async ([handle, intents]) => ({
handle,
intents: (await mapIntentNames(intents)).join(', '),
})));
@@ -128,16 +128,12 @@ export async function register() {
try {
await refresh(handle);
- console.log('refresh done');
map = list();
- console.log('map is now', map);
handles = await Promise.all(Array.from(map.entries()).map(async ([handle, intents]) => ({
handle,
intents: (await mapIntentNames(intents)).join(', '),
})));
- console.log('handles', handles);
const html = await app.parseAndTranslate('modals/intents/register', 'handles', { handles });
- console.log('target el', modal.find('#intents-registered-list'));
modal.find('#intents-registered-list').html(html);
} catch (e) {
alerts.error(e.message);
@@ -197,11 +193,11 @@ export async function trigger(intent, parameters) {
const requiredIntent = intent.toLowerCase();
const displayKey = INTENT_DISPLAY_MAP[requiredIntent];
- const displayIntent = (await translateKeys([`[[${displayKey || intent}]]`]))[0];
+ const displayIntent = (await translate([`[[${displayKey || intent}]]`]));
const entries = Array.from(map.entries())
- .filter(entry => entry.intents && typeof entry.intents === 'object' && requiredIntent in entry.intents)
- .map(entry => ({ handle: entry.handle, intents: entry.intents }));
+ .filter(([, intents]) => intents && typeof intents === 'object' && requiredIntent in intents)
+ .map(([handle, intents]) => ({ handle, intents }));
const matchingHandles = await Promise.all(entries.map(async ({ handle, intents }) => ({
handle,