This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / lib / components / welcome / draft.svelte.ts
1.3 kB 33 lines
1// what the user has entered so far. the step panes are destroyed and recreated on 2// every transition, so this cannot live inside them — the appview has the same 3// split for a different reason, keeping progress in the `onboarding` table and the 4// profile/keys on the record, so wiring this up later means replacing the module 5// rather than moving state around the components. 6 7import { initialKeys, newKey, type MockKey } from "./mock"; 8 9export const draft = $state({ 10 description: "", 11 pronouns: "", 12 website: "", 13 /** a local object url until there is an upload endpoint to post to */ 14 picture: undefined as string | undefined, 15 keys: [...initialKeys] as MockKey[] 16}); 17 18/** the appview greens Next once any profile field has something in it */ 19export const profileFilled = () => 20 [draft.description, draft.pronouns, draft.website].some((value) => value.trim() !== ""); 21 22// the counter lives here rather than in KeysStep: the pane is recreated on every 23// transition, so a component-local counter would restart and collide with the ids 24// already in the list 25let nextKeyId = 1; 26 27export const addKey = (name: string, key: string) => { 28 draft.keys = [...draft.keys, newKey(nextKeyId++, name, key)]; 29}; 30 31export const removeKey = (id: number) => { 32 draft.keys = draft.keys.filter((key) => key.id !== id); 33};