Skip to content

Commit 5370824

Browse files
committed
revert(landing): keep the original changelog timeline (drop useInfiniteQuery)
The React Query conversion of an SSR-seeded, cross-origin, infrequently-changing paginated list introduced caching edge cases (empty-seed load-more, singleton cache serving stale page 1 on client-side nav) without real benefit. Restore the original useState(initialEntries)+fetch timeline, which is simpler, correct, and already review-clean from #5181.
1 parent ecdf4da commit 5370824

2 files changed

Lines changed: 35 additions & 57 deletions

File tree

apps/sim/app/(landing)/changelog/components/changelog-timeline/changelog-timeline.tsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use client'
22

3-
import type { ReactNode } from 'react'
3+
import { type ReactNode, useState } from 'react'
44
import { Streamdown } from 'streamdown'
55
import 'streamdown/styles.css'
66
import { Avatar, AvatarFallback, AvatarImage, Chip, cn } from '@sim/emcn'
7-
import { useChangelogReleases } from '@/app/(landing)/changelog/components/changelog-timeline/use-changelog-releases'
8-
import type { ChangelogEntry } from '@/app/(landing)/changelog/types'
7+
import type { ChangelogEntry, GitHubRelease } from '@/app/(landing)/changelog/types'
8+
import { mapReleases, releasesEndpoint } from '@/app/(landing)/changelog/utils'
99

1010
/**
1111
* The changelog timeline - the single client leaf of the changelog page. Renders
@@ -62,9 +62,35 @@ function formatDate(value: string): string {
6262
}
6363

6464
export function ChangelogTimeline({ initialEntries }: ChangelogTimelineProps) {
65-
const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
66-
useChangelogReleases(initialEntries)
67-
const entries = data?.pages.flat() ?? initialEntries
65+
const [entries, setEntries] = useState<ChangelogEntry[]>(initialEntries)
66+
const [page, setPage] = useState<number>(1)
67+
const [loading, setLoading] = useState<boolean>(false)
68+
const [done, setDone] = useState<boolean>(false)
69+
70+
const loadMore = async () => {
71+
if (loading || done) return
72+
setLoading(true)
73+
try {
74+
const nextPage = page + 1
75+
// boundary-raw-fetch: external GitHub Releases API (cross-origin), not a same-origin contract
76+
const res = await fetch(releasesEndpoint(nextPage), {
77+
headers: { Accept: 'application/vnd.github+json' },
78+
})
79+
const releases = (await res.json()) as GitHubRelease[]
80+
const mapped = mapReleases(releases ?? [])
81+
82+
if (mapped.length === 0) {
83+
setDone(true)
84+
} else {
85+
setEntries((prev) => [...prev, ...mapped])
86+
setPage(nextPage)
87+
}
88+
} catch {
89+
setDone(true)
90+
} finally {
91+
setLoading(false)
92+
}
93+
}
6894

6995
return (
7096
<div className='flex flex-col gap-7'>
@@ -187,10 +213,10 @@ export function ChangelogTimeline({ initialEntries }: ChangelogTimelineProps) {
187213
)
188214
})}
189215

190-
{hasNextPage ? (
216+
{!done ? (
191217
<div>
192-
<Chip type='button' flush onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
193-
{isFetchingNextPage ? 'Loading…' : 'Show more'}
218+
<Chip type='button' flush onClick={loadMore} disabled={loading}>
219+
{loading ? 'Loading…' : 'Show more'}
194220
</Chip>
195221
</div>
196222
) : null}

apps/sim/app/(landing)/changelog/components/changelog-timeline/use-changelog-releases.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)