({
squad,
user,
}: {
squad?: Pick<Squad, 'id' | 'handle'>;
user?: Pick<LoggedUser, 'id'>;
})
| 406 | const SQUAD_PINNED_POSTS_PAGE_SIZE = 10; |
| 407 | |
| 408 | export const squadPinnedPostsQueryOptions = ({ |
| 409 | squad, |
| 410 | user, |
| 411 | }: { |
| 412 | squad?: Pick<Squad, 'id' | 'handle'>; |
| 413 | user?: Pick<LoggedUser, 'id'>; |
| 414 | }) => ({ |
| 415 | queryKey: generateQueryKey(RequestKey.Squad, user, squad?.handle, 'pinned'), |
| 416 | queryFn: async (): Promise<Post[]> => { |
| 417 | const res = await gqlBatchRequest<FeedData>(SOURCE_FEED_QUERY, { |
| 418 | source: squad?.id, |
| 419 | first: SQUAD_PINNED_POSTS_PAGE_SIZE, |
| 420 | loggedIn: !!user, |
| 421 | ranking: RankingAlgorithm.Time, |
| 422 | supportedTypes: baseFeedSupportedTypes, |
| 423 | }); |
| 424 | |
| 425 | return res.page.edges |
| 426 | .map(({ node }) => node) |
| 427 | .filter((post) => !!post.pinnedAt); |
| 428 | }, |
| 429 | enabled: !!squad?.id, |
| 430 | staleTime: StaleTime.Default, |
| 431 | }); |
| 432 | |
| 433 | // The pins come first and are dropped, so the page has room for them and a |
| 434 | // screen of the newest posts after. |
no test coverage detected