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

Function squadPinnedPostsQueryOptions

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

Source from the content-addressed store, hash-verified

406const SQUAD_PINNED_POSTS_PAGE_SIZE = 10;
407
408export 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.

Callers 2

SquadPinnedPostsFunction · 0.90
PostOptionButtonContentFunction · 0.90

Calls 1

generateQueryKeyFunction · 0.90

Tested by

no test coverage detected