From 2cbaa7f0a3d2887029a6a759d8476e777dd44d28 Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:49:29 +0100 Subject: [PATCH] Fix post websites on q-chat --- .../plugins/core/components/ChatScroller.js | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/plugins/plugins/core/components/ChatScroller.js b/plugins/plugins/core/components/ChatScroller.js index 1c2a249a..299339fc 100644 --- a/plugins/plugins/core/components/ChatScroller.js +++ b/plugins/plugins/core/components/ChatScroller.js @@ -50,19 +50,20 @@ const extractComponents = async (url) => { } url = url.replace(/^(qortal:\/\/)/, ''); + if (url.startsWith('use-')) { - // Handle the new 'use' format - let parts = url.split('/'); - const type = parts[0].split('-')[1]; // e.g., 'group' from 'use-group' - parts.shift(); - const action = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., 'invite' from 'action-invite' - parts.shift(); - const idPrefix = parts.length > 0 ? parts[0].split('-')[0] : null; // e.g., 'groupid' from 'groupid-321' - const id = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., '321' from 'groupid-321' - return { - type: type, - action: action, - [idPrefix]: id + // Handle the new 'use' format + let parts = url.split('/'); + const type = parts[0].split('-')[1]; // e.g., 'group' from 'use-group' + parts.shift(); + const action = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., 'invite' from 'action-invite' + parts.shift(); + const idPrefix = parts.length > 0 ? parts[0].split('-')[0] : null; // e.g., 'groupid' from 'groupid-321' + const id = parts.length > 0 ? parts[0].split('-')[1] : null; // e.g., '321' from 'groupid-321' + return { + type: type, + action: action, + [idPrefix]: id } } else if (url.includes('/')) { let parts = url.split('/'); @@ -101,15 +102,13 @@ const extractComponents = async (url) => { }; function processText(input) { - const linkRegex = /(qortal:\/\/\S+)/g; + const linkRegex = /(qortal:\/\/S+)/g; function processNode(node) { if (node.nodeType === Node.TEXT_NODE) { const parts = node.textContent.split(linkRegex); - - if (parts.length > 1) { + if (parts.length > 0) { const fragment = document.createDocumentFragment(); - parts.forEach((part) => { if (part.startsWith('qortal://')) { const link = document.createElement('span'); @@ -2536,4 +2535,4 @@ class ChatMenu extends LitElement { } } -window.customElements.define('chat-menu', ChatMenu); +window.customElements.define('chat-menu', ChatMenu); \ No newline at end of file