Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

routeReveal.ts

28 lines1.0 KB

1// Owned by AppSidebarLayout because the narrow drawer and Settings unmount the
2// thread sidebar without changing the route. Only a route change requests a
3// reveal that may widen the project scope, so a scope chosen while one thread
4// stays open survives a remount. Scroll position does not survive one.
5//
6// A null key is not an observation: leaving Settings commits the router's
7// location before its matches, so the sidebar's first render can read no
8// thread params. Recording that would make the same thread look new.
9export interface SidebarRouteReveal {
10 observedKey: string | null;
11 pendingKey: string | null;
13​
14export function pendingSidebarRouteReveal(
15 reveal: SidebarRouteReveal,
16 routeKey: string | null,
17): string | null {
18 if (routeKey === null) return null;
19 if (reveal.observedKey !== routeKey) {
20 reveal.observedKey = routeKey;
21 reveal.pendingKey = routeKey;
22 }
23 return reveal.pendingKey;
25​
26export function completeSidebarRouteReveal(reveal: SidebarRouteReveal): void {
27 reveal.pendingKey = null;