diff --git a/frontend/src/Widget.jsx b/frontend/src/Widget.jsx
index 1e0735c..f22849a 100644
--- a/frontend/src/Widget.jsx
+++ b/frontend/src/Widget.jsx
@@ -12,7 +12,7 @@ import Col from 'react-bootstrap/Col';
import Stack from 'react-bootstrap/Stack';
import { EventDirection, WidgetEventCapability } from 'matrix-widget-api';
// import { MuiCapabilitiesGuard } from '@matrix-widget-toolkit/mui';
-import { useWidgetApi } from '@matrix-widget-toolkit/react';
+// import { useWidgetApi } from '@matrix-widget-toolkit/react';
import useList from './utils/List';
import { getContractAddressByChainId } from './utils/contract-config';
@@ -49,7 +49,7 @@ function Widget() {
const [showAddPost, setShowAddPost] = useState(false);
const [showViewPost, setShowViewPost] = useState(false);
const [viewPost, setViewPost] = useState({});
- const widgetApi = useWidgetApi();
+ const widgetApi = useRef();
const web3ProviderValue = useMemo(() => ({
provider,
DAO,
@@ -250,6 +250,13 @@ function Widget() {
// api.start();
// }, []);
+ useEffect(() => {
+ console.log('window.location', window.location);
+ window.widgetApiPromise.then((api) => {
+ widgetApi.current = api;
+ });
+ }, []);
+
/* -------------------------------------------------------------------------------- */
/* --------------------------- BEGIN UI ACTIONS ----------------------------------- */
/* -------------------------------------------------------------------------------- */
@@ -334,13 +341,13 @@ function Widget() {
// TODO: Sign and send a message to the forum-api bot / to a room in matrix
const registerMatrixIdentity = async () => {
- await widgetApi.requestCapabilities([
+ await widgetApi.current.requestCapabilities([
WidgetEventCapability.forRoomEvent(
EventDirection.Send,
'm.message',
),
]);
- widgetApi.sendRoomEvent('m.message', 'test message');
+ widgetApi.current.sendRoomEvent('m.message', 'test message');
};
/* -------------------------------------------------------------------------------- */
diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx
index 3edc853..3ddfdd2 100644
--- a/frontend/src/main.jsx
+++ b/frontend/src/main.jsx
@@ -9,11 +9,10 @@ import {
} from 'react-router-dom';
import { WidgetApiImpl } from '@matrix-widget-toolkit/api';
-import { WidgetApiProvider } from '@matrix-widget-toolkit/react';
import WebApp from './WebApp';
import Widget from './Widget';
-const widgetApiPromise = WidgetApiImpl.create();
+window.widgetApiPromise = WidgetApiImpl.create({});
const router = createBrowserRouter([
{
@@ -22,10 +21,7 @@ const router = createBrowserRouter([
},
{
path: 'widget/',
- element:
-
-
- ,
+ element: ,
},
]);