diff --git a/src/config/keys.ts b/src/config/keys.ts index 6731707e..342230eb 100644 --- a/src/config/keys.ts +++ b/src/config/keys.ts @@ -51,7 +51,7 @@ export const itemKeys = { allChildren, // itemKeys.single(id).children([one, two]) - children: (types?: UnionOfConst[]) => + children: (types: UnionOfConst[] = []) => [...allChildren, types] as const, // todo: add page and filtering options diff --git a/src/ws/hooks/item.ts b/src/ws/hooks/item.ts index 850d3454..84244aac 100644 --- a/src/ws/hooks/item.ts +++ b/src/ws/hooks/item.ts @@ -220,6 +220,12 @@ export const configureWsItemHooks = ( console.error('unhandled event for useChildrenUpdates'); break; } + + // TODO: when the backend is updated correctly with the web sockets, + // it will be possible to remove all the manipulations of the cache. + queryClient.invalidateQueries( + itemKeys.single(parentId).allChildren, + ); } } };