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'
|
|
|
|
import { t } from '../../utils/intl'
|
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-05 15:11:14 +00:00
|
|
|
<Show when={isLoaded()} fallback={t('Loading')}>
|
|
|
|
<FeedView articles={props.feedArticles} />
|
|
|
|
</Show>
|
2022-09-22 09:37:49 +00:00
|
|
|
</MainLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// for lazy loading
|
|
|
|
export default FeedPage
|