MCPcopy Create free account
hub / github.com/campsite/campsite / useGetProjectPosts

Function useGetProjectPosts

apps/web/hooks/useGetProjectPosts.ts:19–54  ·  view source on GitHub ↗
({
  projectId,
  enabled = true,
  query: _query,
  order = { by: 'last_activity_at', direction: 'desc' },
  hideResolved = false
}: Props)

Source from the content-addressed store, hash-verified

17}
18
19export function useGetProjectPosts({
20 projectId,
21 enabled = true,
22 query: _query,
23 order = { by: 'last_activity_at', direction: 'desc' },
24 hideResolved = false
25}: Props) {
26 const query = _query ?? ''
27 const { scope } = useScope()
28
29 return useInfiniteQuery({
30 queryKey: getProjectsPosts.requestKey({
31 orgSlug: `${scope}`,
32 projectId,
33 order,
34 q: query,
35 hide_resolved: hideResolved
36 }),
37 queryFn: ({ pageParam }) =>
38 getProjectsPosts.request({
39 orgSlug: `${scope}`,
40 projectId,
41 order,
42 limit: 20,
43 after: pageParam,
44 q: query,
45 hide_resolved: hideResolved
46 }),
47 initialPageParam: undefined as string | undefined,
48 getNextPageParam: (lastPage) => lastPage.next_cursor,
49 getPreviousPageParam: (firstPage) => firstPage.prev_cursor,
50 placeholderData: keepPreviousData,
51 refetchOnWindowFocus: true,
52 enabled
53 })
54}

Callers 4

ProjectPostsFunction · 0.90
ProjectPostsFunction · 0.90

Calls 2

useScopeFunction · 0.90
requestMethod · 0.80

Tested by

no test coverage detected