try using matrix-widget-toolkit
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 36s Details

This commit is contained in:
Ladd Hoffman 2024-04-24 18:33:58 -05:00
parent c8eb727bed
commit 3983977436
3 changed files with 981 additions and 36 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,8 @@
"dependencies": {
"@helia/dag-json": "^3.0.2",
"@libp2p/websockets": "^8.0.16",
"@matrix-widget-toolkit/mui": "^1.2.1",
"@matrix-widget-toolkit/react": "^1.0.6",
"@metamask/eth-sig-util": "^7.0.1",
"@metamask/sdk-react": "^0.16.0",
"@multiformats/multiaddr": "^12.2.1",

View File

@ -10,7 +10,9 @@ import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Stack from 'react-bootstrap/Stack';
import { WidgetApi } from 'matrix-widget-api';
import { EventDirection, WidgetEventCapability } from 'matrix-widget-api';
import { MuiCapabilitiesGuard } from '@matrix-widget-toolkit/mui';
import { useWidgetApi } from '@matrix-widget-toolkit/react';
import './App.css';
import useList from './utils/List';
@ -48,7 +50,7 @@ function App() {
const [showAddPost, setShowAddPost] = useState(false);
const [showViewPost, setShowViewPost] = useState(false);
const [viewPost, setViewPost] = useState({});
const widgetApi = useRef();
const widgetApi = useWidgetApi();
const web3ProviderValue = useMemo(() => ({
provider,
DAO,
@ -241,15 +243,13 @@ function App() {
/* --------------------------- END MAIN INITIALIZION EFFECT ----------------------- */
/* -------------------------------------------------------------------------------- */
useEffect(() => {
widgetApi.current = new WidgetApi();
const api = widgetApi.current;
// api.requestCapability(MatrixCapabilities.)
api.on('action:m.message', (ev) => {
console.log('action:m.message', ev);
});
api.start();
}, []);
// useEffect(() => {
// // api.requestCapability(MatrixCapabilities.)
// api.on('action:m.message', (ev) => {
// console.log('action:m.message', ev);
// });
// api.start();
// }, []);
/* -------------------------------------------------------------------------------- */
/* --------------------------- BEGIN UI ACTIONS ----------------------------------- */
@ -335,7 +335,13 @@ function App() {
// TODO: Sign and send a message to the forum-api bot / to a room in matrix
const registerMatrixIdentity = async () => {
widgetApi.current.transport.send('m.message', 'test message');
await widgetApi.requestCapabilities([
WidgetEventCapability.forRoomEvent(
EventDirection.Send,
'm.message',
),
]);
widgetApi.sendRoomEvent('m.message', 'test message');
};
/* -------------------------------------------------------------------------------- */
@ -389,9 +395,18 @@ function App() {
<div>
<Button onClick={() => disconnect()}>Disconnect</Button>
<Button onClick={() => watchReputationToken()}>Watch REP in MetaMask</Button>
<Button onClick={() => registerMatrixIdentity()}>
Register Matrix Identity
</Button>
<MuiCapabilitiesGuard
capabilities={[
WidgetEventCapability.forRoomEvent(
EventDirection.Send,
'm.message',
),
]}
>
<Button onClick={() => registerMatrixIdentity()}>
Register Matrix Identity
</Button>
</MuiCapabilitiesGuard>
</div>
</Stack>
</Col>