mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-18 06:49:50 +02:00
Generalized frontend model store (#193)
This commit is contained in:
@@ -2,12 +2,17 @@ import type { WebsocketEvent, WebsocketRequest } from '@yaakapp-internal/models'
|
||||
import classNames from 'classnames';
|
||||
import { format } from 'date-fns';
|
||||
import { hexy } from 'hexy';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useMemo, useRef, useState } from 'react';
|
||||
import { useCopy } from '../hooks/useCopy';
|
||||
import { useFormatText } from '../hooks/useFormatText';
|
||||
import { usePinnedWebsocketConnection } from '../hooks/usePinnedWebsocketConnection';
|
||||
import {
|
||||
activeWebsocketConnectionAtom,
|
||||
activeWebsocketConnectionsAtom,
|
||||
setPinnedWebsocketConnectionId,
|
||||
useWebsocketEvents,
|
||||
} from '../hooks/usePinnedWebsocketConnection';
|
||||
import { useStateWithDeps } from '../hooks/useStateWithDeps';
|
||||
import { useWebsocketEvents } from '../hooks/useWebsocketEvents';
|
||||
import { languageFromContentType } from '../lib/contentType';
|
||||
import { AutoScroller } from './core/AutoScroller';
|
||||
import { Banner } from './core/Banner';
|
||||
@@ -33,10 +38,9 @@ export function WebsocketResponsePane({ activeRequest }: Props) {
|
||||
const [showingLarge, setShowingLarge] = useState<boolean>(false);
|
||||
const [hexDumps, setHexDumps] = useState<Record<string, boolean>>({});
|
||||
|
||||
const { activeConnection, connections, setPinnedConnectionId } =
|
||||
usePinnedWebsocketConnection(activeRequest);
|
||||
const activeConnection = useAtomValue(activeWebsocketConnectionAtom);
|
||||
const connections = useAtomValue(activeWebsocketConnectionsAtom);
|
||||
|
||||
// const isLoading = activeConnection !== null && activeConnection.state !== 'closed';
|
||||
const events = useWebsocketEvents(activeConnection?.id ?? null);
|
||||
|
||||
const activeEvent = useMemo(
|
||||
@@ -82,7 +86,7 @@ export function WebsocketResponsePane({ activeRequest }: Props) {
|
||||
<RecentWebsocketConnectionsDropdown
|
||||
connections={connections}
|
||||
activeConnection={activeConnection}
|
||||
onPinnedConnectionId={setPinnedConnectionId}
|
||||
onPinnedConnectionId={setPinnedWebsocketConnectionId}
|
||||
/>
|
||||
</HStack>
|
||||
</HStack>
|
||||
|
||||
Reference in New Issue
Block a user