mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 00:49:17 +01:00
Fix grpc/ws events error
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user