From 5b086aab9d9f56d017f7ada98ff7bb623fb50a1c Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Thu, 25 Apr 2024 18:11:16 -0500 Subject: [PATCH] tinkering --- frontend/src/Widget.jsx | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/frontend/src/Widget.jsx b/frontend/src/Widget.jsx index 2cb5da3..e5d6c3f 100644 --- a/frontend/src/Widget.jsx +++ b/frontend/src/Widget.jsx @@ -261,14 +261,14 @@ function Widget() { // widgetApi.current.requestCapability(MatrixCapabilities.AlwaysOnScreen); - widgetApi.current.requestCapabilities([ - WidgetEventCapability.forRoomEvent( - EventDirection.Send, - 'm.message', - ), - ]); + // widgetApi.current.requestCapabilities([ + // WidgetEventCapability.forRoomEvent( + // EventDirection.Send, + // 'm.message', + // ), + // ]); - widgetApi.current.updateRequestedCapabilities(); + // widgetApi.current.updateRequestedCapabilities(); widgetApi.current.on('ready', (e) => { console.log('WIDGET READY', e); @@ -365,13 +365,17 @@ function Widget() { // TODO: Sign and send a message to the forum-api bot / to a room in matrix const registerMatrixIdentity = async () => { - // await widgetApi.current.requestCapabilities([ - // WidgetEventCapability.forRoomEvent( - // EventDirection.Send, - // 'm.message', - // ), - // ]); - await widgetApi.current.sendRoomEvent('m.message', 'test message', '!HMoNkuTRLqQGhhlMNO:matrix.dgov.io'); + const sendMessageCapability = WidgetEventCapability.forRoomEvent( + EventDirection.Send, + 'm.message', + ); + widgetApi.current.requestCapability(sendMessageCapability); + await widgetApi.current.updateRequestedCapabilities(); + if (widgetApi.current.hasCapability(sendMessageCapability)) { + await widgetApi.current.sendRoomEvent('m.message', 'test message', '!HMoNkuTRLqQGhhlMNO:matrix.dgov.io'); + } else { + console.log('Widget has not been granted the send message capability'); + } }; /* -------------------------------------------------------------------------------- */