webapp/src/components/Pages/AllTopicsPage.tsx

31 lines
763 B
TypeScript
Raw Normal View History

2022-11-14 17:41:05 +00:00
import { PageWrap } from '../_shared/PageWrap'
2022-09-22 09:37:49 +00:00
import { AllTopicsView } from '../Views/AllTopics'
import type { PageProps } from '../types'
2022-11-15 09:38:12 +00:00
import { createSignal, onMount, Show } from 'solid-js'
import { loadAllTopics } from '../../stores/zine/topics'
import { Loading } from '../Loading'
2022-09-22 09:37:49 +00:00
export const AllTopicsPage = (props: PageProps) => {
2022-11-15 09:38:12 +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 (
<PageWrap>
2022-11-15 09:38:12 +00:00
<Show when={isLoaded()} fallback={<Loading />}>
2022-10-05 15:11:14 +00:00
<AllTopicsView topics={props.allTopics} />
2022-11-15 09:38:12 +00:00
</Show>
</PageWrap>
2022-09-22 09:37:49 +00:00
)
}
// for lazy loading
export default AllTopicsPage