fix(app): unblock host index redirect on native by dropping window.location read
`window` exists on React Native (aliased to `global`) but `window.location` is undefined, so reading `window.location.pathname` threw and killed the redirect effect — leaving the host index route stuck rendering null (blank screen). Use the `pathname` from `usePathname()` directly, restoring the pre-refactor behavior that worked on both web and native.
This commit is contained in:
@@ -14,13 +14,6 @@ import { prepareWorkspaceTab } from "@/utils/workspace-navigation";
|
|||||||
|
|
||||||
const HOST_ROOT_REDIRECT_DELAY_MS = 300;
|
const HOST_ROOT_REDIRECT_DELAY_MS = 300;
|
||||||
|
|
||||||
function getCurrentPathname(fallbackPathname: string): string {
|
|
||||||
if (typeof window === "undefined") {
|
|
||||||
return fallbackPathname;
|
|
||||||
}
|
|
||||||
return window.location.pathname || fallbackPathname;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function HostIndexRoute() {
|
export default function HostIndexRoute() {
|
||||||
return (
|
return (
|
||||||
<HostRouteBootstrapBoundary>
|
<HostRouteBootstrapBoundary>
|
||||||
@@ -50,13 +43,11 @@ function HostIndexRouteContent() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rootRoute = buildHostRootRoute(serverId);
|
const rootRoute = buildHostRootRoute(serverId);
|
||||||
const currentPathname = getCurrentPathname(pathname);
|
if (pathname !== rootRoute && pathname !== `${rootRoute}/`) {
|
||||||
if (currentPathname !== rootRoute && currentPathname !== `${rootRoute}/`) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
const latestPathname = getCurrentPathname(pathname);
|
if (pathname !== rootRoute && pathname !== `${rootRoute}/`) {
|
||||||
if (latestPathname !== rootRoute && latestPathname !== `${rootRoute}/`) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user