Skip to content

Commit

Permalink
[Changelog] Fix front page not showing any if latest releases were in…
Browse files Browse the repository at this point in the history
…ternals
  • Loading branch information
ShootingStar91 committed Nov 9, 2023
1 parent 3474d6b commit 21d2e8b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions services/frontend/src/components/Frontpage/Changelog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ export const Changelog = ({ showFullChangelog }) => {
const [itemsToShow, setItemsToShow] = useState([])
const { data, isLoading } = useGetChangelogQuery()

const filterInternalReleases = release => !release.title.startsWith('Internal:')

useEffect(() => {
if (!data) return
setItemsToShow(showFullChangelog ? [...data.slice(0, 20)] : [...data.slice(0, 2)])
setItemsToShow(
showFullChangelog
? [...data.filter(filterInternalReleases).slice(0, 20)]
: [...data.filter(filterInternalReleases).slice(0, 2)]
)
}, [data, showFullChangelog])

const formatDate = dateString => {
Expand All @@ -30,8 +36,6 @@ export const Changelog = ({ showFullChangelog }) => {
return releaseString
}

const filterInternalReleases = release => !release.title.startsWith('Internal:')

if (isLoading || itemsToShow.length === 0) return <Loader />

return (
Expand All @@ -42,7 +46,7 @@ export const Changelog = ({ showFullChangelog }) => {
<p>Last update on: {builtAt ? formatDate(builtAt) : formatDate(itemsToShow[0].time)}</p>
</>
)}
{itemsToShow.filter(filterInternalReleases).map(release => (
{itemsToShow.map(release => (
<div key={release.time}>
<Divider section />
<ReactMarkdown children={getReleaseString(release)} />
Expand Down

0 comments on commit 21d2e8b

Please sign in to comment.