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

Function getNextOptimisticPinOrder

site/src/api/queries/chats.ts:421–450  ·  view source on GitHub ↗
(queryClient: QueryClient)

Source from the content-addressed store, hash-verified

419};
420
421const getNextOptimisticPinOrder = (queryClient: QueryClient): number => {
422 let maxPinOrder = 0;
423 const queries = queryClient.getQueriesData<
424 TypesGen.Chat[] | { pages: TypesGen.Chat[][]; pageParams: unknown[] }
425 >({
426 queryKey: chatsKey,
427 predicate: isChatListQuery,
428 });
429
430 for (const [, data] of queries) {
431 if (!data) {
432 continue;
433 }
434
435 if (Array.isArray(data)) {
436 for (const chat of data) {
437 maxPinOrder = Math.max(maxPinOrder, chat.pin_order);
438 }
439 continue;
440 }
441
442 for (const page of data.pages) {
443 for (const chat of page) {
444 maxPinOrder = Math.max(maxPinOrder, chat.pin_order);
445 }
446 }
447 }
448
449 return maxPinOrder + 1;
450};
451
452/**
453 * Predicate that matches only chat-list queries (the sidebar), not

Callers 1

pinChatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected