webapp/src/stores/editor.ts

34 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-11-13 06:41:04 +00:00
import { createStorageSignal } from '@solid-primitives/storage'
2022-10-07 19:35:53 +00:00
import type { Reaction } from '../graphql/types.gen'
import { createSignal } from 'solid-js'
2022-11-09 17:57:35 +00:00
2022-11-13 06:41:04 +00:00
// TODO: store drafts
2022-11-09 17:57:35 +00:00
// import type { Draft } from '../components/EditorExample/store/context'
2022-10-05 08:55:26 +00:00
interface Collab {
authors: string[] // slugs
invites?: string[]
createdAt: Date
body?: string
title?: string
}
2022-11-13 06:41:04 +00:00
export const drafts = createStorageSignal<{ [key: string]: string }>('drafts', {}) // save drafts on device
export const [collabs, setCollabs] = createSignal<Collab[]>([]) // save collabs in backend or in p2p network
2022-10-07 19:35:53 +00:00
export const [editorReactions, setReactions] = createSignal<Reaction[]>([])
2022-10-05 08:55:26 +00:00
/*
2022-11-13 06:41:04 +00:00
TODO: approvals and proposals derived stores
2022-10-05 08:55:26 +00:00
const approvals = computed(
reactions,
(rdict) => Object.values(rdict)
.filter((r: Reaction) => r.kind === ReactionKind.Accept)
)
const proposals = computed<Reaction[], typeof reactions>(
reactions,
(rdict) => Object.values(rdict)
.filter((r: Reaction) => r.kind === ReactionKind.Propose)
)
*/