interface: add loaded flag to metadata state

This commit is contained in:
Liam Fitzgerald 2021-09-21 13:39:02 +10:00
parent 9cc2d07a4e
commit d36be73933
2 changed files with 4 additions and 1 deletions

View File

@ -30,6 +30,7 @@ const associations = (json: MetadataUpdate, state: MetadataState): MetadataState
}); });
state.associations = metadata; state.associations = metadata;
state.loaded = true;
} }
return state; return state;
}; };

View File

@ -13,6 +13,7 @@ export const METADATA_MAX_PREVIEW_WAIT = 150000;
export interface MetadataState { export interface MetadataState {
associations: Associations; associations: Associations;
loaded: boolean;
getPreview: (group: string) => Promise<MetadataUpdatePreview getPreview: (group: string) => Promise<MetadataUpdatePreview
>; >;
previews: { previews: {
@ -24,6 +25,7 @@ export interface MetadataState {
const useMetadataState = createState<MetadataState>( const useMetadataState = createState<MetadataState>(
'Metadata', 'Metadata',
(set, get) => ({ (set, get) => ({
loaded: false,
associations: { associations: {
groups: {}, groups: {},
graph: {} graph: {}
@ -53,7 +55,7 @@ const useMetadataState = createState<MetadataState>(
} }
} }
}), }),
[], ['loaded'],
[ [
(set, get) => (set, get) =>
createSubscription('metadata-store', '/all', (j) => { createSubscription('metadata-store', '/all', (j) => {