feat: prevent duplicate initialization of Paarrot API and update server port

This commit is contained in:
2026-03-23 20:34:14 +11:00
parent 5eb937ab3e
commit f76fee23bf
3 changed files with 13 additions and 9 deletions

View File

@@ -18,6 +18,11 @@ import { getCallService } from './features/call/useCall';
*/
let navigateFunction: ((path: string) => void) | null = null;
/**
* Track if the API has been initialized to prevent duplicate listeners
*/
let isInitialized = false;
/**
* Set the navigate function for programmatic navigation
* Call this from your router setup
@@ -38,6 +43,13 @@ export function initPaarrotAPI(matrixClient: MatrixClient) {
return;
}
// Prevent duplicate registrations
if (isInitialized) {
console.log('Paarrot API: Already initialized, skipping');
return;
}
isInitialized = true;
console.log('Paarrot API: Initializing API handler');
// Listen for API actions from the Electron API server

View File

@@ -37,7 +37,6 @@ import { getCurrentSession } 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';
import { AccountSwitcher } from '../../components/account-switcher';
import { getLoginPath, withSearchParam } from '../pathUtils';
@@ -178,13 +177,6 @@ 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();

View File

@@ -102,7 +102,7 @@ export default defineConfig({
publicDir: false,
base: buildConfig.base,
server: {
port: 8080,
port: 38347,
host: '0.0.0.0',
fs: {
// Allow serving files from one level up to the project root