export type EditorBackKind = | 'dashboard' | 'search' | 'inbox' | 'notebook' | 'archive' | 'shared' | 'reminders' | 'generic' type SearchLike = Pick /** * Destination of the editor back button, from the URL that opened the note. * Never inferred from the note's own notebook. */ export function resolveEditorBackKind( pathname: string, searchParams: SearchLike, ): EditorBackKind { const from = searchParams.get('from') if (from === 'dashboard' || searchParams.get('peekNote')) return 'dashboard' if (from === 'search' || Boolean(searchParams.get('search')?.trim())) return 'search' if (pathname.startsWith('/archive')) return 'archive' if (searchParams.get('reminders') === '1') return 'reminders' if (searchParams.get('shared') === '1') return 'shared' if (searchParams.get('notebook')) return 'notebook' if (from === 'inbox' || searchParams.get('forceList') === '1') return 'inbox' return 'generic' } export function editorBackLabelKey(kind: EditorBackKind): string { switch (kind) { case 'dashboard': return 'notes.backToHome' case 'search': return 'notes.backToSearchResults' case 'inbox': return 'notes.backToInbox' case 'notebook': return 'notes.backToNotebook' case 'archive': return 'notes.backToArchive' case 'shared': return 'notes.backToShared' case 'reminders': return 'notes.backToReminders' default: return 'general.back' } }