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