( queryClient: QueryClient, childId: string, )
| 218 | * parent) and when a `deleted` pubsub event arrives for a child chat. |
| 219 | */ |
| 220 | export 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 | |
| 240 | const parseUpdatedAtInstant = (updatedAt: string) => { |
| 241 | const match = updatedAt.match(/^(.*?)(?:\.(\d+))?(Z|[+-]\d\d:\d\d)$/); |
no test coverage detected