diff --git a/src-web/hooks/usePinnedGrpcConnection.ts b/src-web/hooks/usePinnedGrpcConnection.ts index af812d5d..12510523 100644 --- a/src-web/hooks/usePinnedGrpcConnection.ts +++ b/src-web/hooks/usePinnedGrpcConnection.ts @@ -62,6 +62,11 @@ export function useGrpcEvents(connectionId: string | null) { const events = useAtomValue(grpcEventsAtom); useEffect(() => { + if (connectionId == null) { + replaceModelsInStore('grpc_event', []); + return; + } + invoke('plugin:yaak-models|grpc_events', { connectionId }).then((events) => { replaceModelsInStore('grpc_event', events); }); diff --git a/src-web/hooks/usePinnedWebsocketConnection.ts b/src-web/hooks/usePinnedWebsocketConnection.ts index 698d9027..491e4524 100644 --- a/src-web/hooks/usePinnedWebsocketConnection.ts +++ b/src-web/hooks/usePinnedWebsocketConnection.ts @@ -1,6 +1,10 @@ import { invoke } from '@tauri-apps/api/core'; import type { WebsocketConnection, WebsocketEvent } from '@yaakapp-internal/models'; -import { replaceModelsInStore , websocketConnectionsAtom, websocketEventsAtom } from '@yaakapp-internal/models'; +import { + replaceModelsInStore, + websocketConnectionsAtom, + websocketEventsAtom, +} from '@yaakapp-internal/models'; import { atom, useAtomValue } from 'jotai'; import { useEffect } from 'react'; import { atomWithKVStorage } from '../lib/atoms/atomWithKVStorage'; @@ -45,6 +49,11 @@ export function useWebsocketEvents(connectionId: string | null) { const events = useAtomValue(websocketEventsAtom); useEffect(() => { + if (connectionId == null) { + replaceModelsInStore('websocket_event', []); + return; + } + invoke('plugin:yaak-models|websocket_events', { connectionId }).then( (events) => replaceModelsInStore('websocket_event', events), );