2022-09-22 09:37:49 +00:00
|
|
|
import { MainLayout } from '../Layouts/MainLayout'
|
|
|
|
import { AllTopicsView } from '../Views/AllTopics'
|
|
|
|
import type { PageProps } from '../types'
|
2022-10-05 15:11:14 +00:00
|
|
|
import { createSignal, onMount, Show } from 'solid-js'
|
|
|
|
import { loadAllTopics } from '../../stores/zine/topics'
|
2022-10-09 10:56:39 +00:00
|
|
|
import { Loading } from '../Loading'
|
2022-09-22 09:37:49 +00:00
|
|
|
|
|
|
|
export const AllTopicsPage = (props: PageProps) => {
|
2022-10-05 15:11:14 +00:00
|
|
|
const [isLoaded, setIsLoaded] = createSignal<boolean>(Boolean(props.allTopics))
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
if (isLoaded()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
await loadAllTopics()
|
|
|
|
setIsLoaded(true)
|
|
|
|
})
|
|
|
|
|
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
|
|
|
<AllTopicsView topics={props.allTopics} />
|
|
|
|
</Show>
|
2022-09-22 09:37:49 +00:00
|
|
|
</MainLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// for lazy loading
|
|
|
|
export default AllTopicsPage
|