Type the paarrot api, WebKit globals, and plugin command content. [skip build]
Checks / checks (push) Successful in 2m6s
Trigger cinny-mobile / dispatch (push) Successful in 2s

This commit is contained in:
2026-11-02 02:22:02 +11:00
parent b36335cde9
commit 6c8a085ae1
4 changed files with 29 additions and 18 deletions
+9 -11
View File
@@ -7,7 +7,7 @@
* To use this, import and call initPaarrotAPI() early in your app initialization.
*/
import { MatrixClient, Room } from 'matrix-js-sdk';
import { MatrixClient, MsgType, Room } from 'matrix-js-sdk';
import { getHomeRoomPath, getDirectRoomPath, getSpaceRoomPath } from './pages/pathUtils';
import { getCanonicalAliasOrRoomId } from './utils/matrix';
import { getCallService } from './features/call/useCall';
@@ -300,18 +300,16 @@ async function getChannels(matrixClient: MatrixClient) {
/**
* Send a message to a specific room
*/
async function sendMessage(matrixClient: any, roomId: string, message: string) {
async function sendMessage(matrixClient: MatrixClient, roomId: string, message: string) {
const room = matrixClient?.getRoom(roomId);
if (!room) {
throw new Error(`Room not found: ${roomId}`);
}
const content = {
msgtype: 'm.text',
const result = await matrixClient.sendMessage(roomId, {
msgtype: MsgType.Text,
body: message.trim(),
};
const result = await matrixClient.sendMessage(roomId, content);
});
return {
eventId: result.event_id,
@@ -564,7 +562,7 @@ async function getUnreadsByScope(matrixClient: MatrixClient, scope: MessageScope
*/
export function initPaarrotAPI(matrixClient: MatrixClient) {
// Check if we're running in Electron
if (!(window as any).electron?.api?.onAction) {
if (!window.electron?.api?.onAction) {
console.log('Paarrot API: Not running in Electron, skipping API initialization');
return;
}
@@ -579,7 +577,7 @@ export function initPaarrotAPI(matrixClient: MatrixClient) {
console.log('Paarrot API: Initializing API handler');
// Listen for API actions from the Electron API server
(window as any).electron.api.onAction(
window.electron.api.onAction(
async (action: { action: string; params: any; responseChannel: string }) => {
console.log('Paarrot API: Received action:', action.action, action.params);
@@ -656,7 +654,7 @@ export function initPaarrotAPI(matrixClient: MatrixClient) {
}
// Send success response back
(window as any).electron.api.sendResponse(action.responseChannel, {
window.electron?.api?.sendResponse(action.responseChannel, {
success: true,
data: result,
});
@@ -666,7 +664,7 @@ export function initPaarrotAPI(matrixClient: MatrixClient) {
console.error('Paarrot API: Action failed:', action.action, error);
// Send error response back
(window as any).electron.api.sendResponse(action.responseChannel, {
window.electron?.api?.sendResponse(action.responseChannel, {
success: false,
error: error instanceof Error ? error.message : 'Unknown error',
});