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

Function goBackPast

packages/shared/src/components/shell/shellNav.ts:316–329  ·  view source on GitHub ↗
(
  isSameLevel: (pathname: string) => boolean,
  fallback: () => void,
)

Source from the content-addressed store, hash-verified

314// that is not one of them, in one history move so nothing is left to
315// replay; the fallback when the stack holds no such page.
316export const goBackPast = (
317 isSameLevel: (pathname: string) => boolean,
318 fallback: () => void,
319): string | null => {
320 const { routes, pointer } = readStack();
321 for (let i = pointer - 1; i >= 0; i -= 1) {
322 if (!isSameLevel(routes[i].path)) {
323 globalThis.history.go(i - pointer);
324 return routes[i].path;
325 }
326 }
327 fallback();
328 return null;
329};
330
331// The page the current one was opened from, as this tab's stack recorded it.
332export const previousShellPath = (): string | undefined => {

Callers 4

shellNav.spec.tsFile · 0.90
FeedSettingsEditHeaderFunction · 0.90
onPhoneBackFunction · 0.90
SettingsLayoutFunction · 0.90

Calls 1

readStackFunction · 0.85

Tested by

no test coverage detected