Skip to content

Commit

Permalink
fix server side hydration of thread feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Jan 11, 2025
1 parent a5c8215 commit 487f215
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web/src/screens/category/CategoryScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function CategoryScreen(props: ScreenProps) {

<ThreadFeedScreen
initialPage={props.initialPage}
initialPageData={[props.initialThreadList]}
initialPageData={props.initialThreadList}
category={category}
/>
</LStack>
Expand Down
2 changes: 1 addition & 1 deletion web/src/screens/feed/FeedScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function ThreadFeedScreenContent({ initialSession, page }: PageProps) {
<ThreadFeedScreen
initialSession={initialSession}
initialPage={page}
initialPageData={[threads.data]}
initialPageData={threads.data}
/>
);
} catch (e) {
Expand Down
15 changes: 11 additions & 4 deletions web/src/screens/feed/ThreadFeedScreen/useThreadFeedScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import { Account, Category, ThreadListResult } from "@/api/openapi-schema";
export type Props = {
initialSession?: Account;
initialPage: number;
initialPageData?: ThreadListResult[];
initialPageData?: ThreadListResult;
category?: Category;
};

export function useThreadFeedScreen(props: Props) {
const { data, error } = useThreadList({
page: props.initialPage.toString(),
});
const { data, error } = useThreadList(
{
page: props.initialPage.toString(),
},
{
swr: {
fallbackData: props.initialPageData,
},
},
);
if (!data) {
return {
ready: false as const,
Expand Down

0 comments on commit 487f215

Please sign in to comment.