Line data Source code
1 : import * as React from 'react';
2 :
3 : import { CatalogLoaderProvider } from '../../connections/catalog/catalog_loader.js';
4 : import { useConnectionScriptsDispatch } from './session_scripts_registry.js';
5 : import { CATALOG_DID_UPDATE } from './session_scripts.js';
6 :
7 : /// The catalog loader of the app, re-analyzes the scripts of every session that uses a connection
8 : /// whose catalog changed.
9 1 : export function SessionCatalogLoaderProvider(props: { children?: React.ReactElement }) {
10 1 : const connScriptsDispatch = useConnectionScriptsDispatch();
11 1 : const onCatalogDidUpdate = React.useCallback((connectionId: string) => {
12 1 : void connScriptsDispatch(connectionId, { type: CATALOG_DID_UPDATE, value: connectionId });
13 1 : }, [connScriptsDispatch]);
14 1 : return (
15 1 : <CatalogLoaderProvider onCatalogDidUpdate={onCatalogDidUpdate}>
16 1 : {props.children}
17 1 : </CatalogLoaderProvider>
18 : );
19 1 : }
|