Fix grpc/ws events error

This commit is contained in:
Gregory Schier
2025-05-16 13:00:50 -07:00
parent 42e70b941d
commit 432b366105
2 changed files with 15 additions and 1 deletions

View File

@@ -62,6 +62,11 @@ export function useGrpcEvents(connectionId: string | null) {
const events = useAtomValue(grpcEventsAtom);
useEffect(() => {
if (connectionId == null) {
replaceModelsInStore('grpc_event', []);
return;
}
invoke<GrpcEvent[]>('plugin:yaak-models|grpc_events', { connectionId }).then((events) => {
replaceModelsInStore('grpc_event', events);
});

View File

@@ -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<WebsocketEvent[]>('plugin:yaak-models|websocket_events', { connectionId }).then(
(events) => replaceModelsInStore('websocket_event', events),
);