import { createSignal } from "solid-js"; /** * How a thread's replies are laid out: a line, each reply with the conversation it started one * post after another; or a tree, every reply under the one it answers. Kept in this browser. */ type ThreadLayout = "linear" | "tree"; const KEY = "parfait:thread-layout"; const read = (): ThreadLayout => { try { return localStorage.getItem(KEY) === "tree" ? "tree" : "linear"; } catch { return "linear"; } }; const [layout, setLayout] = createSignal(read()); export const threadLayout = layout; export const setThreadLayout = (next: ThreadLayout) => { try { if (next === "tree") localStorage.setItem(KEY, next); else localStorage.removeItem(KEY); } catch {} setLayout(next); };