diff --git a/src/components/GoalsPage/GoalsPage.tsx b/src/components/GoalsPage/GoalsPage.tsx index 4d3f99bbd..d4224f12a 100644 --- a/src/components/GoalsPage/GoalsPage.tsx +++ b/src/components/GoalsPage/GoalsPage.tsx @@ -85,7 +85,10 @@ export const GoalsPage = ({ user, ssrTime }: ExternalPageProps) => { [pages], ); const meta = data?.pages?.[0].meta; - const userFilters = trpc.filter.getUserFilters.useQuery(); + const userFilters = trpc.filter.getUserFilters.useQuery(undefined, { + keepPreviousData: true, + staleTime: refreshInterval, + }); const shadowPreset = userFilters.data?.filter((f) => f.params === queryString)[0]; useEffect(() => { diff --git a/src/pages/goals/index.tsx b/src/pages/goals/index.tsx index 0d256979b..ce41bbc1c 100644 --- a/src/pages/goals/index.tsx +++ b/src/pages/goals/index.tsx @@ -1,18 +1,20 @@ import { GoalsPage } from '../../components/GoalsPage/GoalsPage'; import { declareSsrProps } from '../../utils/declareSsrProps'; -// import { parseFilterValues } from '../../hooks/useUrlFilterParams'; +import { parseFilterValues } from '../../hooks/useUrlFilterParams'; + +const pageSize = 20; export const getServerSideProps = declareSsrProps( async ({ query, ssrHelpers }) => { - // const preset = - typeof query.filter === 'string' ? await ssrHelpers.filter.getById.fetch(query.filter) : undefined; + const preset = + typeof query.filter === 'string' ? await ssrHelpers.filter.getById.fetch(query.filter) : undefined; - await ssrHelpers.goal.getBatch.fetchInfinite({ limit: 20 }); + await ssrHelpers.goal.getBatch.fetchInfinite({ + limit: pageSize, + query: parseFilterValues(preset ? Object.fromEntries(new URLSearchParams(preset.params)) : query), + }); - // await ssrHelpers.filter.getUserFilters.fetch(); - // await ssrHelpers.goal.getUserGoals.fetch( - // parseFilterValues(preset ? Object.fromEntries(new URLSearchParams(preset.params)) : query), - // ); + await ssrHelpers.filter.getUserFilters.fetch(); }, { private: true,