MCPcopy Create free account
hub / github.com/dailydotdev/apps / squadPinnedPostsQueryOptions

Function squadPinnedPostsQueryOptions

packages/shared/src/graphql/squads.ts:417–440  ·  view source on GitHub ↗
({
  squad,
  user,
}: {
  squad?: Pick<Squad, 'id' | 'handle'>;
  user?: Pick<LoggedUser, 'id'>;
})

Source from the content-addressed store, hash-verified

415const SQUAD_PINNED_POSTS_PAGE_SIZE = 10;
416
417export 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.

Callers 2

SquadPinnedPostsFunction · 0.90
PostOptionButtonContentFunction · 0.90

Calls 1

generateQueryKeyFunction · 0.90

Tested by

no test coverage detected