Forward query params while redirecting to /home or /file

This commit is contained in:
Frank Noirot
2024-10-08 12:36:48 -04:00
parent 30a24c8ae6
commit 81411033d7
2 changed files with 13 additions and 7 deletions

View File

@ -71,11 +71,14 @@ const router = createRouter([
children: [
{
path: PATHS.INDEX,
loader: async () => {
loader: async ({ request }) => {
const onDesktop = isDesktop()
const url = new URL(request.url)
return onDesktop
? redirect(PATHS.HOME)
: redirect(PATHS.FILE + '/%2F' + BROWSER_PROJECT_NAME)
? redirect(PATHS.HOME + (url.search || ''))
: redirect(
PATHS.FILE + '/%2F' + BROWSER_PROJECT_NAME + (url.search || '')
)
},
},
{

View File

@ -174,11 +174,14 @@ export const fileLoader: LoaderFunction = async (
// Loads the settings and by extension the projects in the default directory
// and returns them to the Home route, along with any errors that occurred
export const homeLoader: LoaderFunction = async (): Promise<
HomeLoaderData | Response
> => {
export const homeLoader: LoaderFunction = async ({
request,
}): Promise<HomeLoaderData | Response> => {
const url = new URL(request.url)
if (!isDesktop()) {
return redirect(PATHS.FILE + '/%2F' + BROWSER_PROJECT_NAME)
return redirect(
PATHS.FILE + '/%2F' + BROWSER_PROJECT_NAME + (url.search || '')
)
}
return {}
}