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

Function squadPinnedPostsQueryOptions

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

Source from the content-addressed store, hash-verified

403const SQUAD_PINNED_POSTS_PAGE_SIZE = 10;
404
405export 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.

Callers 2

SquadPinnedPostsFunction · 0.90
PostOptionButtonContentFunction · 0.90

Calls 1

generateQueryKeyFunction · 0.90

Tested by

no test coverage detected