Line data Source code
1 : import * as React from 'react';
2 :
3 : import type { QueryExecutionState } from '../query/query_execution_state.js';
4 : import type { ShellQueryExecutionTracker } from '../shell/query_execution.js';
5 :
6 1 : export function useShellQueryResult(queryExecutions: ShellQueryExecutionTracker) {
7 1 : const [resultQuery, setResultQuery] = React.useState<QueryExecutionState | null>(null);
8 1 : const showResultQuery = React.useCallback((queryId: number) => {
9 1 : const query = queryExecutions.getSnapshot().find(candidate => candidate.queryId === queryId) ?? null;
10 1 : setResultQuery(query);
11 1 : }, [queryExecutions]);
12 1 : const closeResultQuery = React.useCallback(() => setResultQuery(null), []);
13 :
14 1 : return { resultQuery, showResultQuery, closeResultQuery };
15 1 : }
|