feat: implement Paarrot API for Electron integration with navigation and IPC handlers

This commit is contained in:
2026-02-21 21:40:38 +11:00
parent 6a31ea64ed
commit ef55d1583f
5 changed files with 903 additions and 53 deletions

View File

@@ -27,6 +27,7 @@ import { useSelectedRoom } from '../../hooks/router/useSelectedRoom';
import { useInboxNotificationsSelected } from '../../hooks/router/useInbox';
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
import { isTauri, sendNotification, setupNotificationTapListener } from '../../utils/tauri';
import { setPaarrotNavigate, initPaarrotAPI } from '../../paarrot-api';
/**
* Applies the selected emoji style font to the document.
@@ -322,6 +323,27 @@ function MessageNotifications() {
);
}
/**
* Initializes the Paarrot API for Electron integration
* Registers the navigate function and sets up IPC handlers
*/
function PaarrotAPIInitializer() {
const navigate = useNavigate();
const mx = useMatrixClient();
useEffect(() => {
// Register navigate function for Paarrot API
setPaarrotNavigate(navigate);
// Initialize Paarrot API handlers
initPaarrotAPI(mx);
console.log('Paarrot API: Initialized with navigate function');
}, [navigate, mx]);
return null;
}
type ClientNonUIFeaturesProps = {
children: ReactNode;
};
@@ -334,6 +356,7 @@ export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) {
<FaviconUpdater />
<InviteNotifications />
<MessageNotifications />
<PaarrotAPIInitializer />
{children}
</>
);

View File

@@ -38,6 +38,7 @@ import { getFallbackSession } from '../../state/sessions';
import { CallProviderWrapper } from '../../features/call/CallProviderWrapper';
import { isTauriMobile, startBackgroundSync, stopBackgroundSync } from '../../utils/tauri';
import { TitleBar } from '../../components/title-bar';
import { initPaarrotAPI } from '../../paarrot-api';
function ClientRootLoading() {
return (
@@ -250,6 +251,13 @@ export function ClientRoot({ children }: ClientRootProps) {
useVisibilitySync(mx);
useBackgroundSync(mx);
// Initialize Paarrot API when client is ready
useEffect(() => {
if (mx) {
initPaarrotAPI(mx);
}
}, [mx]);
useEffect(() => {
if (loadState.status === AsyncStatus.Idle) {
loadMatrix();