Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| The phone app: Chat in full with phone notifications, plus Code and Customize (#4) | 1 | import { router, useLocalSearchParams } from "expo-router"; |
| 2 | import * as WebBrowser from "expo-web-browser"; | |
| 3 | import { useEffect } from "react"; | |
| 4 | ||
| 5 | import { Loading, Screen } from "@/components/ui"; | |
| 6 | import { useSession } from "@/lib/session"; | |
| 7 | import { siteUrl } from "@/lib/server"; | |
| 8 | ||
| 9 | /** | |
| 10 | * A link to a page the app has no screen for: it opens on the site, in | |
| 11 | * the system's browser, and the app goes back to where it was. | |
| 12 | */ | |
| 13 | export default function Open() { | |
| 14 | const { path } = useLocalSearchParams<{ path?: string }>(); | |
| 15 | const { state } = useSession(); | |
| 16 | ||
| 17 | useEffect(() => { | |
| 18 | const server = state.server; | |
| 19 | if (!server) return; | |
| 20 | const safe = path && path.startsWith("/") ? path : "/"; | |
| 21 | void WebBrowser.openBrowserAsync(siteUrl(server, safe)).finally(() => { | |
| 22 | if (router.canGoBack()) router.back(); | |
| 23 | else router.replace("/"); | |
| 24 | }); | |
| 25 | }, [path, state.server]); | |
| 26 | ||
| 27 | return ( | |
| 28 | <Screen> | |
| 29 | <Loading /> | |
| 30 | </Screen> | |
| 31 | ); | |
| 32 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.