widget wip
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 30s Details

This commit is contained in:
Ladd Hoffman 2024-04-25 14:13:31 -05:00
parent fff2526c36
commit f4220cc4f9
2 changed files with 13 additions and 10 deletions

View File

@ -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');
};
/* -------------------------------------------------------------------------------- */

View File

@ -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:
<WidgetApiProvider widgetApiPromise={widgetApiPromise}>
<Widget />
</WidgetApiProvider>,
element: <Widget />,
},
]);