Redirect root to profile home

- send / through the configured profile home page
- keep the router regression test in sync with the redirect
- preserve the legacy shell fallback for non-router bootstrap
This commit is contained in:
Antti Kettunen 2026-04-26 14:01:07 +03:00
parent 86bcad491f
commit f5d70768c1
No known key found for this signature in database
GPG key ID: C6B2A3D250359BD7
2 changed files with 26 additions and 1 deletions

View file

@ -134,4 +134,22 @@ describe('createAppRouter', () => {
expect(history.location.pathname).toBe('/discover');
});
it('redirects the root route to the profile home page', async () => {
window.SoulSyncWebShellBridge = createShellBridge({
getProfileHomePage: vi.fn<() => ShellPageId>(() => 'search'),
});
const queryClient = createAppQueryClient();
const history = createMemoryHistory({ initialEntries: ['/'] });
const router = createAppRouter({ history, queryClient });
render(<AppRouterProvider router={router} queryClient={queryClient} />);
await waitFor(() => {
expect(window.SoulSyncWebShellBridge?.activateLegacyPath).toHaveBeenCalledWith('/search');
});
expect(history.location.pathname).toBe('/search');
});
});

View file

@ -1,8 +1,15 @@
import { createFileRoute } from '@tanstack/react-router';
import { createFileRoute, redirect } from '@tanstack/react-router';
import { getProfileHomePath } from '@/platform/shell/bridge';
import { LegacyRouteController } from '@/platform/shell/route-controllers';
export const Route = createFileRoute('/')({
beforeLoad: ({ context }) => {
const bridge = context.platform.getShellBridge();
if (!bridge) return;
throw redirect({ href: getProfileHomePath(bridge), replace: true });
},
component: IndexRouteComponent,
});