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

Function goBackPast

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

Source from the content-addressed store, hash-verified

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