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