MCPcopy Create free account
hub / github.com/dailydotdev/apps / findIndexOfPostInData

Function findIndexOfPostInData

packages/shared/src/lib/query.ts:633–658  ·  view source on GitHub ↗
(
  data: InfiniteData<AnyFeedData>,
  id: string,
  findBySharedPost = false,
)

Source from the content-addressed store, hash-verified

631};
632
633export const findIndexOfPostInData = (
634 data: InfiniteData<AnyFeedData>,
635 id: string,
636 findBySharedPost = false,
637): { pageIndex: number; index: number } => {
638 for (let pageIndex = 0; pageIndex < data.pages.length; pageIndex += 1) {
639 const page = data.pages[pageIndex];
640 for (let index = 0; index < page.page.edges.length; index += 1) {
641 const item = page.page.edges[index];
642 const post = getFeedApiItemPost(item.node);
643
644 if (post?.id === id) {
645 return { pageIndex, index };
646 }
647 if (
648 post &&
649 findBySharedPost &&
650 post.type === PostType.Share &&
651 post.sharedPost?.id === id
652 ) {
653 return { pageIndex, index };
654 }
655 }
656 }
657 return { pageIndex: -1, index: -1 };
658};
659
660export const updatePostCache = (
661 client: QueryClient,

Callers 5

findPostFunction · 0.90
usePollFunction · 0.90
useFeedFunction · 0.90
useTranslationFunction · 0.90
updateFeedAndAdsCacheFunction · 0.85

Calls 1

getFeedApiItemPostFunction · 0.90

Tested by

no test coverage detected