File
Blob: src/client/lib/shared-inbox-navigation.ts
| 1 | const SHARED_INBOX_RETURN_TO_KEY = "blandSharedInboxReturnTo"; |
| 2 | |
| 3 | export function getSharedInboxReturnTo(state: unknown): string | null { |
| 4 | if (!state || typeof state !== "object") return null; |
| 5 | |
| 6 | const returnTo = (state as Record<string, unknown>)[SHARED_INBOX_RETURN_TO_KEY]; |
| 7 | if (typeof returnTo !== "string" || !returnTo.startsWith("/")) { |
| 8 | return null; |
| 9 | } |
| 10 | |
| 11 | return returnTo; |
| 12 | } |
| 13 | |
| 14 | export function withSharedInboxReturnTo(state: unknown, href: string): Record<string, unknown> { |
| 15 | const base = state && typeof state === "object" ? (state as Record<string, unknown>) : {}; |
| 16 | return { ...base, [SHARED_INBOX_RETURN_TO_KEY]: href }; |
| 17 | } |