webapp/src/stores/zine/currentArticle.ts

26 lines
565 B
TypeScript
Raw Normal View History

2022-09-09 11:53:35 +00:00
import { atom, WritableAtom } from 'nanostores'
import type { Shout } from '../../graphql/types.gen'
import { useStore } from '@nanostores/solid'
let currentArticleStore: WritableAtom<Shout | null>
2022-09-13 09:59:04 +00:00
type InitialState = {
currentArticle: Shout
}
export const useCurrentArticleStore = ({ currentArticle }: InitialState) => {
2022-09-09 11:53:35 +00:00
if (!currentArticleStore) {
2022-09-13 09:59:04 +00:00
currentArticleStore = atom(currentArticle)
2022-09-09 11:53:35 +00:00
}
2022-09-13 09:59:04 +00:00
// FIXME
// addTopicsByAuthor
// addAuthorsByTopic
2022-09-09 11:53:35 +00:00
const getCurrentArticle = useStore(currentArticleStore)
return {
getCurrentArticle
}
}