Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: invalidate all children keys after useChildrenUpdates #650

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const itemKeys = {
allChildren,

// itemKeys.single(id).children([one, two])
children: (types?: UnionOfConst<typeof ItemType>[]) =>
children: (types: UnionOfConst<typeof ItemType>[] = []) =>
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
[...allChildren, types] as const,

// todo: add page and filtering options
Expand Down
6 changes: 6 additions & 0 deletions src/ws/hooks/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
}
}
};
Expand Down