Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| The apps you pin to your dock are kept with your account, per workspace and in your order, so the dock is the same on every device: identity keeps them in dock_pins and answers dock_pins and set_dock_pins, the dock reads them with the rest of the page, pins kept only on this device carry over with your first change, this device's copy still draws the dock when identity can't be reached, a pin that can't be saved says so, and they go when you or the workspace do; the workspaces guide says how. | 1 | /** |
| 2 | * Each person's dock pins, kept with their account by identity | |
| 3 | * (`dock_pins` / `set_dock_pins`), so their dock follows them to every | |
| 4 | * device. lib/apps.ts says which apps can be pinned; identity only keeps | |
| 5 | * the list in order. | |
| 6 | */ | |
| 7 | import type { User } from "@g1t/contracts"; | |
| 8 | ||
| 9 | import { type PinnableApp, pinsFrom } from "./apps"; | |
| 10 | import { identity } from "./services.server"; | |
| 11 | ||
| 12 | /** | |
| 13 | * The pins `user` saved in the workspace `slug`, or null when they never | |
| 14 | * saved any there or identity could not be asked: the caller falls back | |
| 15 | * to the cookie (lib/apps.ts `pinsToShow`). | |
| 16 | */ | |
| 17 | export async function savedPins(user: User, slug: string): Promise<PinnableApp[] | null> { | |
| 18 | try { | |
| 19 | const stored = await identity.dockPins(user, slug); | |
| 20 | return stored ? pinsFrom(stored) : null; | |
| 21 | } catch (error) { | |
| 22 | console.error("dock: pins could not be read", error); | |
| 23 | return null; | |
| 24 | } | |
| 25 | } | |
| 26 | ||
| 27 | /** Saves `pins` as `user`'s in `slug`, in their order; the pins as kept, or null when they could not be saved. */ | |
| 28 | export async function savePins(user: User, slug: string, pins: PinnableApp[]): Promise<PinnableApp[] | null> { | |
| 29 | try { | |
| 30 | const result = await identity.setDockPins(user, slug, pins); | |
| 31 | return result.ok ? pinsFrom(result.value) : null; | |
| 32 | } catch (error) { | |
| 33 | console.error("dock: pins could not be saved", error); | |
| 34 | return null; | |
| 35 | } | |
| 36 | } |