MCPcopy Index your code
hub / github.com/coder/coder / removeChildFromParentInCache

Function removeChildFromParentInCache

site/src/api/queries/chats.ts:220–238  ·  view source on GitHub ↗
(
	queryClient: QueryClient,
	childId: string,
)

Source from the content-addressed store, hash-verified

218 * parent) and when a `deleted` pubsub event arrives for a child chat.
219 */
220export const removeChildFromParentInCache = (
221 queryClient: QueryClient,
222 childId: string,
223) => {
224 let found = false;
225 updateInfiniteChatsCache(queryClient, (chats) => {
226 let changed = false;
227 const next = chats.map((c) => {
228 if (!c.children?.length) return c;
229 const filtered = c.children.filter((ch) => ch.id !== childId);
230 if (filtered.length === c.children.length) return c;
231 found = true;
232 changed = true;
233 return { ...c, children: filtered };
234 });
235 return changed ? next : chats;
236 });
237 return found;
238};
239
240const parseUpdatedAtInstant = (updatedAt: string) => {
241 const match = updatedAt.match(/^(.*?)(?:\.(\d+))?(Z|[+-]\d\d:\d\d)$/);

Callers 3

connectFunction · 0.90
chats.test.tsFile · 0.90
archiveChatFunction · 0.85

Calls 2

updateInfiniteChatsCacheFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected