( data: InfiniteData<AnyFeedData>, id: string, findBySharedPost = false, )
| 631 | }; |
| 632 | |
| 633 | export 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 | |
| 660 | export const updatePostCache = ( |
| 661 | client: QueryClient, |
no test coverage detected