( data: InfiniteData<AnyFeedData>, id: string, findBySharedPost = false, )
| 655 | }; |
| 656 | |
| 657 | export const findIndexOfPostInData = ( |
| 658 | data: InfiniteData<AnyFeedData>, |
| 659 | id: string, |
| 660 | findBySharedPost = false, |
| 661 | ): { pageIndex: number; index: number } => { |
| 662 | for (let pageIndex = 0; pageIndex < data.pages.length; pageIndex += 1) { |
| 663 | const page = data.pages[pageIndex]; |
| 664 | for (let index = 0; index < page.page.edges.length; index += 1) { |
| 665 | const item = page.page.edges[index]; |
| 666 | const post = getFeedApiItemPost(item.node); |
| 667 | |
| 668 | if (post?.id === id) { |
| 669 | return { pageIndex, index }; |
| 670 | } |
| 671 | if ( |
| 672 | post && |
| 673 | findBySharedPost && |
| 674 | post.type === PostType.Share && |
| 675 | post.sharedPost?.id === id |
| 676 | ) { |
| 677 | return { pageIndex, index }; |
| 678 | } |
| 679 | } |
| 680 | } |
| 681 | return { pageIndex: -1, index: -1 }; |
| 682 | }; |
| 683 | |
| 684 | export const updatePostCache = ( |
| 685 | client: QueryClient, |
no test coverage detected