import { createEffect, createSignal, For, onMount, Show } from 'solid-js' import type { Topic } from '../../graphql/types.gen' import { byFirstChar, sortBy } from '../../utils/sortby' import Icon from '../Nav/Icon' import { t } from '../../utils/intl' import { useTopicsStore } from '../../stores/zine/topics' import { by, route, setBy } from '../../stores/router' import { TopicCard } from '../Topic/Card' import { session } from '../../stores/auth' import { useStore } from '@nanostores/solid' import { groupByTitle } from '../../utils/groupby' import '../../styles/AllTopics.scss' export const AllTopicsPage = (props: { topics?: Topic[] }) => { const [sortedTopics, setSortedTopics] = createSignal[]>([]) const [sortedKeys, setSortedKeys] = createSignal() const [abc, setAbc] = createSignal([]) const { getSortedTopics: topicslist } = useTopicsStore({ topics: props.topics }) const auth = useStore(session) const subscribed = (s) => Boolean(auth()?.info?.topics && auth()?.info?.topics?.includes(s || '')) createEffect(() => { if (!by() && abc().length === 0) { console.log('[topics] default grouping by abc') const grouped = { ...groupByTitle(topicslist()) } grouped['A-Z'] = sortBy(grouped['A-Z'], byFirstChar) setAbc(grouped) const keys = Object.keys(abc) keys.sort() setSortedKeys(keys as string[]) } else { console.log('[topics] sorting by ' + by()) setSortedTopics(sortBy(topicslist(), by())) } }, [topicslist(), by()]) onMount(() => setBy('')) return ( <>
(
{(topic: Topic) => ( )}
)} > {(letter: string) => (

{letter}

{(topic: Partial) => ( )}
)}
) }