mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix randomItems and images api url on android
This commit is contained in:
parent
6e530786b9
commit
a6eb744cc9
@ -18,6 +18,7 @@
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { HomePage } from "@kyoo/ui";
|
||||
import { HomePage, BrowsePage } from "@kyoo/ui";
|
||||
import { withRoute } from "../utils";
|
||||
|
||||
export default HomePage;
|
||||
export default withRoute(BrowsePage);
|
41
front/apps/mobile/app/(public)/_layout.tsx
Normal file
41
front/apps/mobile/app/(public)/_layout.tsx
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { NavbarTitle } from "@kyoo/ui";
|
||||
import { Stack } from "expo-router";
|
||||
import { useTheme } from "yoshiki/native";
|
||||
|
||||
export default function PublicLayout() {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={{
|
||||
headerTitle: () => <NavbarTitle />,
|
||||
contentStyle: {
|
||||
backgroundColor: theme.background,
|
||||
},
|
||||
headerStyle: {
|
||||
backgroundColor: theme.accent,
|
||||
},
|
||||
headerTintColor: theme.colors.white,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
@ -23,6 +23,8 @@ import { ComponentType, useEffect } from "react";
|
||||
import { StatusBar, StatusBarProps } from "react-native";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
import * as NavigationBar from "expo-navigation-bar";
|
||||
import arrayShuffle from "array-shuffle";
|
||||
import { QueryPage } from "@kyoo/models";
|
||||
|
||||
const FullscreenProvider = () => {
|
||||
useEffect(() => {
|
||||
@ -52,7 +54,12 @@ export const withRoute = <Props,>(
|
||||
{routeOptions && <Stack.Screen {...routeOptions} />}
|
||||
{statusBar && <StatusBar {...statusBar} />}
|
||||
{fullscreen && <FullscreenProvider />}
|
||||
<Component {...defaultProps} {...routeParams} {...props} />
|
||||
<Component
|
||||
{...defaultProps}
|
||||
randomItems={arrayShuffle((Component as QueryPage).randomItems ?? [])}
|
||||
{...routeParams}
|
||||
{...props}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -31,19 +31,12 @@ import { KyooErrors } from "./kyoo-errors";
|
||||
import { Page, Paged } from "./page";
|
||||
import { Platform } from "react-native";
|
||||
import { getToken } from "./login";
|
||||
import { getCurrentAccount } from "./account-internal";
|
||||
|
||||
const kyooUrl =
|
||||
Platform.OS !== "web"
|
||||
? process.env.PUBLIC_BACK_URL
|
||||
: typeof window === "undefined"
|
||||
? process.env.KYOO_URL ?? "http://localhost:5000"
|
||||
: "/api";
|
||||
|
||||
export let kyooApiUrl: string | null = kyooUrl || null;
|
||||
|
||||
export const setApiUrl = (apiUrl: string) => {
|
||||
kyooApiUrl = apiUrl;
|
||||
};
|
||||
typeof window === "undefined" ? process.env.KYOO_URL ?? "http://localhost:5000" : "/api";
|
||||
// The url of kyoo, set after each query (used by the image parser).
|
||||
export let kyooApiUrl = kyooUrl;
|
||||
|
||||
export const queryFn = async <Data,>(
|
||||
context:
|
||||
@ -60,8 +53,7 @@ export const queryFn = async <Data,>(
|
||||
token?: string | null,
|
||||
): Promise<Data> => {
|
||||
// @ts-ignore
|
||||
let url: string | null = context.apiUrl ?? kyooApiUrl;
|
||||
if (!url) console.error("Kyoo's url is not defined.");
|
||||
const url = context.apiUrl ?? (Platform.OS === "web" ? kyooUrl : getCurrentAccount()!.apiUrl);
|
||||
kyooApiUrl = url;
|
||||
|
||||
// @ts-ignore
|
||||
@ -71,8 +63,8 @@ export const queryFn = async <Data,>(
|
||||
"path" in context
|
||||
? (context.path.filter((x) => x) as string[])
|
||||
: "pageParam" in context && context.pageParam
|
||||
? [context.pageParam as string]
|
||||
: (context.queryKey.filter((x) => x) as string[]),
|
||||
? [context.pageParam as string]
|
||||
: (context.queryKey.filter((x) => x) as string[]),
|
||||
)
|
||||
.join("/")
|
||||
.replace("/?", "?");
|
||||
@ -93,7 +85,7 @@ export const queryFn = async <Data,>(
|
||||
signal: controller?.signal,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("Fetch error", e);
|
||||
console.log("Fetch error", e, path);
|
||||
throw { errors: ["Could not reach Kyoo's server."] } as KyooErrors;
|
||||
}
|
||||
if (resp.status === 404) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user