/** The footer's usage figures: what is left of the plan (subscription only) and what this session used. */ import { useEffect, useReducer } from "preact/hooks"; import { onUsage, startUsage, usageNow, view } from "./usage"; export function Usage() { const [, tick] = useReducer((x: number) => x + 1, 0); useEffect(() => { const off = onUsage(() => tick(0)); const stop = startUsage(); return () => { off(); stop(); }; }, []); const v = view(usageNow()); if (!v) return null; return ( {v.plan && ( {v.plan.text} )} {v.session && ( {v.session.text} )} ); }