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