webapp/src/components/Pages/FeedPage.tsx

34 lines
856 B
TypeScript
Raw Normal View History

2022-09-22 09:37:49 +00:00
import { MainLayout } from '../Layouts/MainLayout'
import { FeedView } from '../Views/Feed'
import type { PageProps } from '../types'
2022-10-05 15:11:14 +00:00
import { createSignal, onCleanup, onMount, Show } from 'solid-js'
import { loadRecentArticles, resetSortedArticles } from '../../stores/zine/articles'
2022-10-09 10:56:39 +00:00
import { Loading } from '../Loading'
2022-09-22 09:37:49 +00:00
export const FeedPage = (props: PageProps) => {
2022-10-05 15:11:14 +00:00
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.feedArticles))
onMount(async () => {
if (isLoaded()) {
return
}
await loadRecentArticles({ limit: 50, offset: 0 })
setIsLoaded(true)
})
onCleanup(() => resetSortedArticles())
2022-09-22 09:37:49 +00:00
return (
<MainLayout>
2022-10-09 10:56:39 +00:00
<Show when={isLoaded()} fallback={<Loading />}>
2022-10-05 15:11:14 +00:00
<FeedView articles={props.feedArticles} />
</Show>
2022-09-22 09:37:49 +00:00
</MainLayout>
)
}
// for lazy loading
export default FeedPage