MCPcopy Create free account
hub / github.com/dailydotdev/apps / readStack

Function readStack

packages/shared/src/components/shell/shellNav.ts:166–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164const emptyStack = (): RouteStack => ({ routes: [], pointer: -1 });
165
166const readStack = (): RouteStack => {
167 try {
168 const parsed = JSON.parse(
169 globalThis.sessionStorage?.getItem(stackKey) ?? 'null',
170 ) as RouteStack | null;
171 if (
172 parsed &&
173 Array.isArray(parsed.routes) &&
174 parsed.routes.every((entry) => typeof entry?.key === 'string')
175 ) {
176 return parsed;
177 }
178 } catch {
179 // fall through to an empty stack
180 }
181 return emptyStack();
182};
183
184const writeStack = (stack: RouteStack) => {
185 try {

Callers 4

recordShellRouteFunction · 0.85
goBackPastFunction · 0.85
previousShellPathFunction · 0.85
canGoBackInAppFunction · 0.85

Calls 1

emptyStackFunction · 0.85

Tested by

no test coverage detected