diff --git a/front/apps/mobile/app/(app)/(tabs)/downloads.tsx b/front/apps/mobile/app/(app)/(tabs)/downloads.tsx deleted file mode 100644 index dfb44d79..00000000 --- a/front/apps/mobile/app/(app)/(tabs)/downloads.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { DownloadPage } from "@kyoo/ui"; - -export default DownloadPage; diff --git a/front/apps/mobile/app/(app)/(tabs)/index.tsx b/front/apps/mobile/app/(app)/(tabs)/index.tsx deleted file mode 100644 index fb6a7dd1..00000000 --- a/front/apps/mobile/app/(app)/(tabs)/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 . - */ - -import { HomePage } from "@kyoo/ui"; -import { withRoute } from "../../utils"; - -export default withRoute(HomePage, { - options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } }, - statusBar: { barStyle: "light-content" }, -}); diff --git a/front/apps/mobile/app/(app)/admin/index.tsx b/front/apps/mobile/app/(app)/admin/index.tsx deleted file mode 100644 index b057197b..00000000 --- a/front/apps/mobile/app/(app)/admin/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { AdminPage } from "@kyoo/ui"; - -export default AdminPage; diff --git a/front/apps/mobile/app/(app)/collection/[slug]/index.tsx b/front/apps/mobile/app/(app)/collection/[slug]/index.tsx deleted file mode 100644 index 58686664..00000000 --- a/front/apps/mobile/app/(app)/collection/[slug]/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 . - */ - -import { CollectionPage } from "@kyoo/ui"; -import { withRoute } from "../../../utils"; - -export default withRoute(CollectionPage, { - options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } }, - statusBar: { barStyle: "light-content" }, -}); diff --git a/front/apps/mobile/app/(app)/movie/[slug]/index.tsx b/front/apps/mobile/app/(app)/movie/[slug]/index.tsx deleted file mode 100644 index fd97ad59..00000000 --- a/front/apps/mobile/app/(app)/movie/[slug]/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 . - */ - -import { MovieDetails } from "@kyoo/ui"; -import { withRoute } from "../../../utils"; - -export default withRoute(MovieDetails, { - options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } }, - statusBar: { barStyle: "light-content" }, -}); diff --git a/front/apps/mobile/app/(app)/movie/[slug]/watch.tsx b/front/apps/mobile/app/(app)/movie/[slug]/watch.tsx deleted file mode 100644 index 9f86bca1..00000000 --- a/front/apps/mobile/app/(app)/movie/[slug]/watch.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 . - */ - -import { Player } from "@kyoo/ui"; -import { withRoute } from "../../../utils"; - -export default withRoute( - Player, - { - options: { - headerShown: false, - navigationBarHidden: true, - }, - statusBar: { hidden: true }, - fullscreen: true, - }, - { type: "movie" }, -); diff --git a/front/apps/mobile/app/(app)/search/index.tsx b/front/apps/mobile/app/(app)/search/index.tsx deleted file mode 100644 index 4c0d1c88..00000000 --- a/front/apps/mobile/app/(app)/search/index.tsx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 . - */ - -import { SearchPage } from "@kyoo/ui"; -import { Stack, useLocalSearchParams } from "expo-router"; -import { useTranslation } from "react-i18next"; -import { createParam } from "solito"; -import { useRouter } from "solito/router"; -import { useTheme } from "yoshiki/native"; - -const { useParam } = createParam<{ q?: string }>(); - -const Search = () => { - const theme = useTheme(); - const { back } = useRouter(); - const { t } = useTranslation(); - const [query, setQuery] = useParam("q"); - const routeParams = useLocalSearchParams(); - - return ( - <> - null, - // TODO: this shouuld not be null but since the header right is on the left of the search bar. shrug - headerRight: () => null, - headerSearchBarOptions: { - autoFocus: true, - headerIconColor: theme.colors.white, - hintTextColor: theme.light.overlay1, - textColor: theme.paragraph, - placeholder: t("navbar.search")!, - onClose: () => back(), - onChangeText: (e) => setQuery(e.nativeEvent.text), - }, - }} - /> - - - ); -}; - -export default Search; diff --git a/front/apps/mobile/app/(app)/settings/index.tsx b/front/apps/mobile/app/(app)/settings/index.tsx deleted file mode 100644 index 7a987194..00000000 --- a/front/apps/mobile/app/(app)/settings/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { SettingsPage } from "@kyoo/ui"; - -export default SettingsPage; diff --git a/front/apps/mobile/app/(app)/show/[slug].tsx b/front/apps/mobile/app/(app)/show/[slug].tsx deleted file mode 100644 index 7cef6bda..00000000 --- a/front/apps/mobile/app/(app)/show/[slug].tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 . - */ - -import { ShowDetails } from "@kyoo/ui"; -import { withRoute } from "../../utils"; - -export default withRoute(ShowDetails, { - options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } }, - statusBar: { barStyle: "light-content" }, -}); diff --git a/front/apps/mobile/app/(app)/watch/[slug].tsx b/front/apps/mobile/app/(app)/watch/[slug].tsx deleted file mode 100644 index 3b2e4e9f..00000000 --- a/front/apps/mobile/app/(app)/watch/[slug].tsx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 . - */ - -import { Player } from "@kyoo/ui"; -import { withRoute } from "../../utils"; - -export default withRoute( - Player, - { - options: { - headerShown: false, - navigationBarHidden: true, - }, - statusBar: { hidden: true }, - fullscreen: true, - }, - { type: "episode" }, -); diff --git a/front/apps/mobile/app/(public)/_layout.tsx b/front/apps/mobile/app/(public)/_layout.tsx deleted file mode 100644 index 90dfb3de..00000000 --- a/front/apps/mobile/app/(public)/_layout.tsx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 . - */ - -import { type Account, ConnectionErrorContext, useAccount } from "@kyoo/models"; -import { NavbarProfile, NavbarTitle } from "@kyoo/ui"; -import { Redirect, Stack } from "expo-router"; -import { useContext, useRef } from "react"; -import { useTheme } from "yoshiki/native"; - -export default function PublicLayout() { - const theme = useTheme(); - const account = useAccount(); - const { error } = useContext(ConnectionErrorContext); - const oldAccount = useRef(account); - - if (account && !error && account !== oldAccount.current) return ; - oldAccount.current = account; - - return ( - , - headerRight: () => , - contentStyle: { - backgroundColor: theme.background, - }, - headerStyle: { - backgroundColor: theme.accent, - }, - headerTintColor: theme.colors.white, - }} - /> - ); -} diff --git a/front/apps/mobile/app/(public)/connection-error.tsx b/front/apps/mobile/app/(public)/connection-error.tsx deleted file mode 100644 index a7d7d1c7..00000000 --- a/front/apps/mobile/app/(public)/connection-error.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { ConnectionError } from "@kyoo/ui"; - -export default ConnectionError; diff --git a/front/apps/mobile/app/(public)/login/callback.tsx b/front/apps/mobile/app/(public)/login/callback.tsx deleted file mode 100644 index 2a69ad49..00000000 --- a/front/apps/mobile/app/(public)/login/callback.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { OidcCallbackPage } from "@kyoo/ui"; -import { withRoute } from "../../utils"; - -export default withRoute(OidcCallbackPage); diff --git a/front/apps/mobile/app/(public)/login/index.tsx b/front/apps/mobile/app/(public)/login/index.tsx deleted file mode 100644 index 43bc741c..00000000 --- a/front/apps/mobile/app/(public)/login/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { LoginPage } from "@kyoo/ui"; -import { withRoute } from "../../utils"; - -export default withRoute(LoginPage); diff --git a/front/apps/mobile/app/(public)/register/index.tsx b/front/apps/mobile/app/(public)/register/index.tsx deleted file mode 100644 index a44e4006..00000000 --- a/front/apps/mobile/app/(public)/register/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { RegisterPage } from "@kyoo/ui"; -import { withRoute } from "../../utils"; - -export default withRoute(RegisterPage); diff --git a/front/apps/mobile/app/(public)/server-url/index.tsx b/front/apps/mobile/app/(public)/server-url/index.tsx deleted file mode 100644 index 8b0fe80f..00000000 --- a/front/apps/mobile/app/(public)/server-url/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { ServerUrlPage } from "@kyoo/ui"; - -export default ServerUrlPage; diff --git a/front/apps/mobile/app/(public)/settings/index.tsx b/front/apps/mobile/app/(public)/settings/index.tsx deleted file mode 100644 index 7a987194..00000000 --- a/front/apps/mobile/app/(public)/settings/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { SettingsPage } from "@kyoo/ui"; - -export default SettingsPage; diff --git a/front/apps/mobile/app/_layout.tsx b/front/apps/mobile/app/_layout.tsx deleted file mode 100644 index cd9caf64..00000000 --- a/front/apps/mobile/app/_layout.tsx +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 . - */ - -import "react-native-reanimated"; - -import { - Poppins_300Light, - Poppins_400Regular, - Poppins_900Black, - useFonts, -} from "@expo-google-fonts/poppins"; -import { PortalProvider } from "@gorhom/portal"; -import { AccountProvider, createQueryClient, storage, useUserTheme } from "@kyoo/models"; -import { SnackbarProvider, ThemeSelector } from "@kyoo/primitives"; -import { DownloadProvider } from "@kyoo/ui"; -import { ThemeProvider as RNThemeProvider } from "@react-navigation/native"; -import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister"; -import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"; -import { getLocales } from "expo-localization"; -import { Slot } from "expo-router"; -import * as SplashScreen from "expo-splash-screen"; -import i18next from "i18next"; -import "intl-pluralrules"; -import { type ReactNode, useEffect, useState } from "react"; -import { initReactI18next } from "react-i18next"; -import { useColorScheme } from "react-native"; -import resources from "../../../translations"; - -import NetInfo from "@react-native-community/netinfo"; -import { onlineManager } from "@tanstack/react-query"; -import { useTheme } from "yoshiki/native"; - -onlineManager.setEventListener((setOnline) => { - return NetInfo.addEventListener((state) => { - setOnline(!!state.isConnected); - }); -}); - -const clientStorage = { - setItem: (key, value) => { - storage.set(key, value); - }, - getItem: (key) => { - const value = storage.getString(key); - return value === undefined ? null : value; - }, - removeItem: (key) => { - storage.delete(key); - }, -} satisfies Partial; - -export const clientPersister = createSyncStoragePersister({ storage: clientStorage }); - -const sysLang = getLocales()[0].languageCode ?? "en"; -i18next.use(initReactI18next).init({ - interpolation: { - escapeValue: false, - }, - returnEmptyString: false, - fallbackLng: "en", - lng: storage.getString("language") ?? sysLang, - resources, -}); -// @ts-expect-error Manually added value -i18next.systemLanguage = sysLang; - -const NavigationThemeProvider = ({ children }: { children: ReactNode }) => { - const theme = useTheme(); - return ( - - {children} - - ); -}; - -SplashScreen.preventAutoHideAsync(); - -export default function Root() { - const [queryClient] = useState(() => createQueryClient()); - let theme = useUserTheme(); - const systemTheme = useColorScheme(); - const [fontsLoaded] = useFonts({ Poppins_300Light, Poppins_400Regular, Poppins_900Black }); - - if (theme === "auto") theme = systemTheme ?? "light"; - - useEffect(() => { - if (fontsLoaded) SplashScreen.hideAsync(); - }, [fontsLoaded]); - - if (!fontsLoaded) return null; - return ( - false }, - }} - onSuccess={async () => { - await queryClient.resumePausedMutations(); - queryClient.invalidateQueries(); - }} - > - - - - - - - - - - - - - - - ); -} diff --git a/front/apps/mobile/app/utils.tsx b/front/apps/mobile/app/utils.tsx deleted file mode 100644 index 85725f30..00000000 --- a/front/apps/mobile/app/utils.tsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 . - */ - -import { type QueryPage, useHasPermission } from "@kyoo/models"; -import { Unauthorized } from "@kyoo/ui"; -import arrayShuffle from "array-shuffle"; -import * as NavigationBar from "expo-navigation-bar"; -import { Stack, useLocalSearchParams } from "expo-router"; -import * as ScreenOrientation from "expo-screen-orientation"; -import { type ComponentType, useEffect } from "react"; -import { StatusBar, type StatusBarProps } from "react-native"; - -const FullscreenProvider = () => { - useEffect(() => { - ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE); - NavigationBar.setVisibilityAsync("hidden"); - return () => { - ScreenOrientation.unlockAsync(); - NavigationBar.setVisibilityAsync("visible"); - }; - }, []); - return null; -}; - -export const withRoute = ( - Component: ComponentType, - options?: Parameters[0] & { - statusBar?: StatusBarProps; - fullscreen?: boolean; - }, - defaultProps?: Partial, -) => { - const { statusBar, fullscreen, ...routeOptions } = options ?? {}; - const WithUseRoute = (props: any) => { - const routeParams = useLocalSearchParams(); - const hasPermissions = useHasPermission((Component as QueryPage).requiredPermissions ?? []); - - if (!hasPermissions) - return ; - - return ( - <> - {routeOptions && } - {statusBar && } - {fullscreen && } - - - ); - }; - - const { ...all } = Component; - Object.assign(WithUseRoute, { ...all }); - return WithUseRoute; -}; diff --git a/front/apps/mobile/assets/icon.png b/front/apps/mobile/assets/icon.png deleted file mode 100644 index a395f0fe..00000000 Binary files a/front/apps/mobile/assets/icon.png and /dev/null differ diff --git a/front/apps/mobile/metro.config.js b/front/apps/mobile/metro.config.js deleted file mode 100644 index 9ba7f3d0..00000000 --- a/front/apps/mobile/metro.config.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 . - */ - -const { getDefaultConfig } = require("expo/metro-config"); -const path = require("node:path"); - -const projectRoot = __dirname; -const defaultConfig = getDefaultConfig(projectRoot); - -function addMonorepoSupport(config) { - const workspaceRoot = path.resolve(projectRoot, "../.."); - - return { - ...config, - watchFolders: [...config.watchFolders, workspaceRoot], - resolver: { - ...config.resolver, - nodeModulesPaths: [ - ...config.resolver.nodeModulesPaths, - path.resolve(projectRoot, "node_modules"), - path.resolve(workspaceRoot, "node_modules"), - ], - disableHierarchicalLookup: true, - }, - }; -} - -function addSvgTransformer(config) { - return { - ...config, - transformer: { - ...config.transformer, - babelTransformerPath: require.resolve("react-native-svg-transformer"), - }, - resolver: { - ...config.resolver, - assetExts: config.resolver.assetExts.filter((ext) => ext !== "svg"), - sourceExts: [...config.resolver.sourceExts, "svg"], - }, - }; -} - -module.exports = addMonorepoSupport( - addSvgTransformer({ - ...defaultConfig, - resolver: { - ...defaultConfig.resolver, - requireCycleIgnorePatterns: [...defaultConfig.resolver.requireCycleIgnorePatterns, /.*/], - }, - }), -); diff --git a/front/apps/mobile/tsconfig.json b/front/apps/mobile/tsconfig.json deleted file mode 100644 index 9eeb5906..00000000 --- a/front/apps/mobile/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "expo/tsconfig.base", - "compilerOptions": { - "strict": true - }, - "include": [ - "**/*.ts", - "**/*.tsx", - "../../packages/ui/src/i18n-d.d.ts", - "../../packages/ui/src/svg.d.ts" - ] -} diff --git a/front/apps/web/next.config.js b/front/apps/web/next.config.js deleted file mode 100755 index 12d4c490..00000000 --- a/front/apps/web/next.config.js +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 . - */ - -const path = require("node:path"); -const CopyPlugin = require("copy-webpack-plugin"); -const DefinePlugin = require("webpack").DefinePlugin; - -const suboctopus = path.resolve(path.dirname(require.resolve("jassub")), "../dist"); - -/** - * @type {import("next").NextConfig} - */ -const nextConfig = { - swcMinify: true, - // can't be true since we would run hls cleanup twice and run on race conditions - reactStrictMode: false, - output: "standalone", - webpack: (config) => { - config.plugins = [ - ...config.plugins, - new CopyPlugin({ - patterns: [ - { - context: suboctopus, - from: "*", - filter: (filepath) => !filepath.endsWith(".es.js"), - to: "static/chunks/", - }, - ], - }), - ]; - config.resolve = { - ...config.resolve, - alias: { - ...config.resolve.alias, - "react-native$": "react-native-web", - // "react-native/Libraries/Image/AssetRegistry$": - // "react-native-web/dist/modules/AssetRegistry", - "react-native/Libraries/EventEmitter/RCTDeviceEventEmitter$": - "react-native-web/dist/vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter", - "react-native/Libraries/vendor/emitter/EventEmitter$": - "react-native-web/dist/vendor/react-native/emitter/EventEmitter", - "react-native/Libraries/EventEmitter/NativeEventEmitter$": - "react-native-web/dist/vendor/react-native/NativeEventEmitter", - }, - extensions: [".web.ts", ".web.tsx", ".web.js", ".web.jsx", ...config.resolve.extensions], - }; - - if (!config.plugins) config.plugins = []; - config.plugins.push( - new DefinePlugin({ - __DEV__: JSON.stringify(process.env.NODE_ENV !== "production"), - }), - ); - - config.module.rules.push({ - test: /\.svg$/i, - issuer: /\.[jt]sx?$/, - use: [ - { - loader: "@svgr/webpack", - options: { - native: true, - svgoConfig: { - plugins: [ - { - name: "removeViewBox", - active: false, - }, - ], - }, - }, - }, - ], - }); - return config; - }, - i18n: { - locales: ["en", "fr"], - defaultLocale: "en", - }, - transpilePackages: [ - "@kyoo/ui", - "@kyoo/primitives", - "@kyoo/models", - "@react-native/assets-registry", - "solito", - "react-native", - "react-native-web", - "react-native-svg", - "react-native-reanimated", - "react-native-mmkv", - "moti", - "yoshiki", - "@expo/vector-icons", - "@expo/html-elements", - "expo-font", - "expo-asset", - "expo-av", - "expo-modules-core", - "expo-linear-gradient", - "expo-image-picker", - ], - experimental: { - outputFileTracingRoot: path.join(__dirname, "../../"), - }, -}; - -if (process.env.NODE_ENV !== "production") { - nextConfig.rewrites = async () => [ - { - source: "/api/:path*", - destination: process.env.KYOO_URL - ? `${process.env.KYOO_URL}/:path*` - : "http://localhost:5000/:path*", - }, - ]; -} - -module.exports = nextConfig; diff --git a/front/apps/web/src/i18n.tsx b/front/apps/web/src/i18n.tsx deleted file mode 100644 index af53fc3a..00000000 --- a/front/apps/web/src/i18n.tsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 . - */ - -import { readCookie } from "@kyoo/models/src/account-internal"; -import i18next, { type InitOptions } from "i18next"; -import type { AppContext, AppInitialProps, AppProps } from "next/app"; -import { type ComponentType, useState } from "react"; -import { I18nextProvider } from "react-i18next"; -import resources from "../../../translations"; - -export const withTranslations = ( - AppToTranslate: ComponentType & { - getInitialProps: (ctx: AppContext) => Promise; - }, -) => { - const i18n = i18next.createInstance(); - const commonOptions: InitOptions = { - interpolation: { - escapeValue: false, - }, - returnEmptyString: false, - fallbackLng: "en", - resources, - }; - - const AppWithTranslations = (props: AppProps) => { - const [li18n] = useState(() => { - if (typeof window === "undefined") return i18n; - i18next.init({ - ...commonOptions, - lng: props.pageProps.__lang, - }); - i18next.systemLanguage = props.pageProps?.__sysLang; - return i18next; - }); - - return ( - - - - ); - }; - AppWithTranslations.getInitialProps = async (ctx: AppContext) => { - const props: AppInitialProps = await AppToTranslate.getInitialProps(ctx); - const sysLng = ctx.router.locale || ctx.router.defaultLocale || "en"; - const lng = readCookie(ctx.ctx.req?.headers.cookie, "language") || sysLng; - await i18n.init({ - ...commonOptions, - lng, - }); - i18n.systemLanguage = sysLng; - props.pageProps ??= {}; - props.pageProps.__lang = lng; - props.pageProps.__sysLang = sysLng; - return props; - }; - - return AppWithTranslations; -}; diff --git a/front/apps/web/src/pages/_app.tsx b/front/apps/web/src/pages/_app.tsx deleted file mode 100755 index fd330e51..00000000 --- a/front/apps/web/src/pages/_app.tsx +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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 . - */ - -import "../polyfill"; - -import { PortalProvider } from "@gorhom/portal"; -import { - AccountP, - AccountProvider, - ConnectionErrorContext, - type QueryIdentifier, - type QueryPage, - type ServerInfo, - ServerInfoP, - SetupStep, - UserP, - createQueryClient, - fetchQuery, - getTokenWJ, - setSsrApiUrl, - useFetch, - useUserTheme, -} from "@kyoo/models"; -import { getCurrentAccount, readCookie, updateAccount } from "@kyoo/models/src/account-internal"; -import { - HiddenIfNoJs, - SkeletonCss, - SnackbarProvider, - ThemeSelector, - TouchOnlyCss, -} from "@kyoo/primitives"; -import { WebTooltip } from "@kyoo/primitives/src/tooltip.web"; -import { ConnectionError } from "@kyoo/ui"; -import { HydrationBoundary, QueryClientProvider, dehydrate } from "@tanstack/react-query"; -import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; -import arrayShuffle from "array-shuffle"; -import NextApp, { type AppContext, type AppProps } from "next/app"; -import { Poppins } from "next/font/google"; -import Head from "next/head"; -import { type NextRouter, useRouter } from "next/router"; -import { type ComponentType, useContext, useEffect, useState } from "react"; -import { Tooltip } from "react-tooltip"; -import superjson from "superjson"; -import { StyleRegistryProvider, useMobileHover, useStyleRegistry, useTheme } from "yoshiki/web"; -import { withTranslations } from "../i18n"; - -const font = Poppins({ weight: ["300", "400", "900"], subsets: ["latin"], display: "swap" }); - -const YoshikiDebug = ({ children }: { children: JSX.Element }) => { - if (typeof window === "undefined") return children; - const registry = useStyleRegistry(); - return {children}; -}; - -const ConnectionErrorVerifier = ({ - children, - skipErrors, -}: { - children: JSX.Element; - skipErrors?: boolean; -}) => { - const { error } = useContext(ConnectionErrorContext); - - if (!error || skipErrors) return children; - return ; -}; - -const SetupChecker = () => { - const { data } = useFetch({ path: ["info"], parser: ServerInfoP }); - const router = useRouter(); - - const step = data?.setupStatus; - - useEffect(() => { - if (!step) return; - if (step !== SetupStep.Done && !SetupChecker.isRouteAllowed(router, step)) - router.push(`/setup?step=${step}`); - if (step === SetupStep.Done && router.route === "/setup") router.replace("/"); - }, [router.route, step, router]); - - return null; -}; - -SetupChecker.isRouteAllowed = (router: NextRouter, step: SetupStep) => - (router.route === "/setup" && router.query.step === step) || - router.route === "/register" || - router.route.startsWith("/login") || - router.route === "/settings"; - -const WithLayout = ({ Component, ...props }: { Component: ComponentType }) => { - const layoutInfo = (Component as QueryPage).getLayout ?? (({ page }) => page); - const { Layout, props: layoutProps } = - typeof layoutInfo === "function" ? { Layout: layoutInfo, props: {} } : layoutInfo; - return } randomItems={[]} {...layoutProps} />; -}; - -const App = ({ Component, pageProps }: AppProps) => { - const [queryClient] = useState(() => createQueryClient()); - const { queryState, ssrError, token, randomItems, account, theme, ...props } = - superjson.deserialize(pageProps ?? { json: {} }); - const userTheme = useUserTheme(theme); - useMobileHover(); - - // Set the auth from the server (if the token was refreshed during SSR). - if (typeof window !== "undefined" && token) { - const account = getCurrentAccount(); - if (account) updateAccount(account.id, { ...account, token }); - } - - return ( - - <> - - Kyoo - - - - - - - - - - - - - - - - - - - - - - - - ); -}; - -App.getInitialProps = async (ctx: AppContext) => { - const appProps = await NextApp.getInitialProps(ctx); - const Component = ctx.Component as QueryPage; - - const items = arrayShuffle(Component.randomItems ?? []); - appProps.pageProps.randomItems = { - [Component.displayName!]: items, - }; - - if (typeof window !== "undefined") return { pageProps: superjson.serialize(appProps.pageProps) }; - - try { - const getUrl = Component.getFetchUrls; - const getLayoutUrl = - Component.getLayout && "Layout" in Component.getLayout - ? Component.getLayout.Layout.getFetchUrls - : Component.getLayout?.getFetchUrls; - const urls: QueryIdentifier[] = [ - ...(getUrl ? getUrl(ctx.router.query as any, items) : []), - ...(getLayoutUrl ? getLayoutUrl(ctx.router.query as any, items) : []), - // always include server info for guest permissions. - { path: ["info"], parser: ServerInfoP }, - ]; - - setSsrApiUrl(); - - appProps.pageProps.theme = readCookie(ctx.ctx.req?.headers.cookie, "theme") ?? "auto"; - - const account = readCookie(ctx.ctx.req?.headers.cookie, "account", AccountP); - if (account) urls.push({ path: ["auth", "me"], parser: UserP }); - const [authToken, token, error] = await getTokenWJ(account); - if (error) appProps.pageProps.ssrError = error; - const client = (await fetchQuery(urls, authToken))!; - appProps.pageProps.queryState = dehydrate(client); - if (account) { - appProps.pageProps.token = token; - appProps.pageProps.account = { - ...client.getQueryData(["auth", "me"]), - ...account, - }; - } - - const info = client.getQueryData(["info"]); - if ( - info!.setupStatus !== SetupStep.Done && - !SetupChecker.isRouteAllowed(ctx.router, info!.setupStatus) - ) { - ctx.ctx.res!.writeHead(307, { Location: `/setup?step=${info!.setupStatus}` }); - ctx.ctx.res!.end(); - return { pageProps: {} }; - } - if (info!.setupStatus === SetupStep.Done && ctx.router.route === "/setup") { - ctx.ctx.res!.writeHead(307, { Location: "/" }); - ctx.ctx.res!.end(); - return { pageProps: {} }; - } - } catch (e) { - console.error("SSR error, disabling it."); - } - return { pageProps: superjson.serialize(appProps.pageProps) }; -}; - -export default withTranslations(App); diff --git a/front/apps/web/src/pages/_document.tsx b/front/apps/web/src/pages/_document.tsx deleted file mode 100644 index 7583f1dd..00000000 --- a/front/apps/web/src/pages/_document.tsx +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 . - */ - -import { type DocumentContext, Head, Html, Main, NextScript } from "next/document"; -import { AppRegistry } from "react-native"; -import { StyleRegistryProvider, createStyleRegistry } from "yoshiki/web"; - -export const style = ` -/** - * Building on the RNWeb reset: - * https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/exports/StyleSheet/initialRules.js - */ -html, body, #__next { - width: 100%; - /* To smooth any scrolling behavior */ - -webkit-overflow-scrolling: touch; - margin: 0px; - padding: 0px; - /* Allows content to fill the viewport and go beyond the bottom */ - min-height: 100%; -} -#__next { - flex-shrink: 0; - flex-basis: auto; - flex-direction: column; - flex-grow: 1; - display: flex; - flex: 1; - overflow: hidden; -} -html { - scroll-behavior: smooth; - /* Prevent text size change on orientation change https://gist.github.com/tfausak/2222823#file-ios-8-web-app-html-L138 */ - -webkit-text-size-adjust: 100%; - height: 100%; -} -body { - display: flex; - /* Allows you to scroll below the viewport; default value is visible */ - overflow-y: auto; - overscroll-behavior-y: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -ms-overflow-style: scrollbar; -} -`; - -const Document = () => { - return ( - - - - - - - - - -
- - - - ); -}; - -Document.getInitialProps = async (ctx: DocumentContext) => { - const renderPage = ctx.renderPage; - const registry = createStyleRegistry(); - - ctx.renderPage = () => - renderPage({ - enhanceApp: (App) => (props) => { - return ( - - - - ); - }, - }); - - const props = await ctx.defaultGetInitialProps(ctx); - - AppRegistry.registerComponent("Main", () => Main); - // @ts-ignore React native web missing type. - const { getStyleElement } = AppRegistry.getApplication("Main"); - const page = await ctx.renderPage(); - - return { - ...props, - ...page, - styles: ( - <> - {props.styles} - {page.styles} - - {getStyleElement()} - {registry.flushToComponent()} - - ), - }; -}; -export default Document; diff --git a/front/apps/web/src/pages/admin/index.tsx b/front/apps/web/src/pages/admin/index.tsx deleted file mode 100644 index 829344ec..00000000 --- a/front/apps/web/src/pages/admin/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { AdminPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(AdminPage); diff --git a/front/apps/web/src/pages/browse/index.tsx b/front/apps/web/src/pages/browse/index.tsx deleted file mode 100644 index e756ef4e..00000000 --- a/front/apps/web/src/pages/browse/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { BrowsePage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(BrowsePage); diff --git a/front/apps/web/src/pages/collection/[slug]/index.tsx b/front/apps/web/src/pages/collection/[slug]/index.tsx deleted file mode 100644 index afc0749b..00000000 --- a/front/apps/web/src/pages/collection/[slug]/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { CollectionPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(CollectionPage); diff --git a/front/apps/web/src/pages/index.tsx b/front/apps/web/src/pages/index.tsx deleted file mode 100755 index ecef0601..00000000 --- a/front/apps/web/src/pages/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 . - */ - -import { HomePage } from "@kyoo/ui"; - -export default HomePage; diff --git a/front/apps/web/src/pages/login/callback.tsx b/front/apps/web/src/pages/login/callback.tsx deleted file mode 100644 index 9735f32e..00000000 --- a/front/apps/web/src/pages/login/callback.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { OidcCallbackPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(OidcCallbackPage); diff --git a/front/apps/web/src/pages/login/index.tsx b/front/apps/web/src/pages/login/index.tsx deleted file mode 100644 index 8bc2c179..00000000 --- a/front/apps/web/src/pages/login/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { LoginPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(LoginPage); diff --git a/front/apps/web/src/pages/movie/[slug]/index.tsx b/front/apps/web/src/pages/movie/[slug]/index.tsx deleted file mode 100644 index 157b1ace..00000000 --- a/front/apps/web/src/pages/movie/[slug]/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { MovieDetails } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(MovieDetails); diff --git a/front/apps/web/src/pages/movie/[slug]/watch.tsx b/front/apps/web/src/pages/movie/[slug]/watch.tsx deleted file mode 100644 index 17349725..00000000 --- a/front/apps/web/src/pages/movie/[slug]/watch.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { Player } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(Player, { type: "movie" }); diff --git a/front/apps/web/src/pages/register/index.tsx b/front/apps/web/src/pages/register/index.tsx deleted file mode 100644 index 0558bfc1..00000000 --- a/front/apps/web/src/pages/register/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { RegisterPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(RegisterPage); diff --git a/front/apps/web/src/pages/search/index.tsx b/front/apps/web/src/pages/search/index.tsx deleted file mode 100644 index b85ad55d..00000000 --- a/front/apps/web/src/pages/search/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { SearchPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(SearchPage); diff --git a/front/apps/web/src/pages/settings/index.tsx b/front/apps/web/src/pages/settings/index.tsx deleted file mode 100644 index 22fe9369..00000000 --- a/front/apps/web/src/pages/settings/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { SettingsPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(SettingsPage); diff --git a/front/apps/web/src/pages/setup/index.tsx b/front/apps/web/src/pages/setup/index.tsx deleted file mode 100644 index 022e242e..00000000 --- a/front/apps/web/src/pages/setup/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { SetupPage } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(SetupPage); diff --git a/front/apps/web/src/pages/show/[slug].tsx b/front/apps/web/src/pages/show/[slug].tsx deleted file mode 100644 index 7d5aca9b..00000000 --- a/front/apps/web/src/pages/show/[slug].tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { ShowDetails } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(ShowDetails); diff --git a/front/apps/web/src/pages/watch/[slug].tsx b/front/apps/web/src/pages/watch/[slug].tsx deleted file mode 100644 index a26ad2ca..00000000 --- a/front/apps/web/src/pages/watch/[slug].tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -import { Player } from "@kyoo/ui"; -import { withRoute } from "~/router"; - -export default withRoute(Player, { type: "episode" }); diff --git a/front/apps/web/src/polyfill.ts b/front/apps/web/src/polyfill.ts deleted file mode 100644 index a1b77565..00000000 --- a/front/apps/web/src/polyfill.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 . - */ - -// import "raf/polyfill"; -// import "setimmediate"; -// import "react-native-reanimated"; -import React from "react"; - -// // FIXME need reanimated update, see https://github.com/software-mansion/react-native-reanimated/issues/3355 -// if (typeof window !== "undefined") { -// // @ts-ignore -// window._frameTimestamp = null; -// } -// Simply silence a SSR warning (see https://github.com/facebook/react/issues/14927 for more details) -if (typeof window === "undefined") { - React.useLayoutEffect = React.useEffect; -} diff --git a/front/apps/web/src/router.tsx b/front/apps/web/src/router.tsx deleted file mode 100644 index dee9eb60..00000000 --- a/front/apps/web/src/router.tsx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 . - */ - -import { type QueryPage, useHasPermission } from "@kyoo/models"; -import { Unauthorized } from "@kyoo/ui"; -import { useRouter } from "next/router"; -import type { ComponentType } from "react"; - -export const withRoute = ( - Component: ComponentType, - defaultProps?: Partial, -) => { - const WithUseRoute = (props: Props) => { - const router = useRouter(); - const hasPermissions = useHasPermission((Component as QueryPage).requiredPermissions ?? []); - - if (!hasPermissions) - return ; - return ; - }; - - const { ...all } = Component; - Object.assign(WithUseRoute, { ...all }); - if ("getFetchUrls" in Component) { - const oldGet = Component.getFetchUrls as (obj: object) => object; - WithUseRoute.getFetchUrls = (props: object) => oldGet({ ...defaultProps, ...props }); - } - - return WithUseRoute; -}; diff --git a/front/apps/web/tsconfig.json b/front/apps/web/tsconfig.json deleted file mode 100755 index 7ac1302d..00000000 --- a/front/apps/web/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "baseUrl": ".", - "paths": { - "~/*": ["src/*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "../../packages/ui/src/i18n-d.d.ts"], - "exclude": ["node_modules"] -} diff --git a/front/packages/ui/src/search/index.tsx b/front/packages/ui/src/search/index.tsx deleted file mode 100644 index fd1283cc..00000000 --- a/front/packages/ui/src/search/index.tsx +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 . - */ - -import { type LibraryItem, LibraryItemP, type QueryIdentifier, type QueryPage } from "@kyoo/models"; -import { usePageStyle } from "@kyoo/primitives"; -import { useState } from "react"; -import { useTranslation } from "react-i18next"; -import { createParam } from "solito"; -import { createFilterString, getMediaTypeFromParam, itemMap } from "../browse"; -import { ItemGrid } from "../browse/grid"; -import { BrowseSettings } from "../browse/header"; -import { ItemList } from "../browse/list"; -import { Layout, type MediaType, MediaTypes, SearchSort, SortOrd } from "../browse/types"; -import { InfiniteFetch } from "../fetch-infinite"; -import { DefaultLayout } from "../layout"; - -const { useParam } = createParam<{ sortBy?: string; mediaType?: string }>(); - -const query = ( - mediaType: MediaType, - query?: string, - sortKey?: SearchSort, - sortOrd?: SortOrd, -): QueryIdentifier => ({ - parser: LibraryItemP, - path: ["search", "items"], - infinite: true, - params: { - q: query, - filter: createFilterString(mediaType), - sortBy: - sortKey && sortKey !== SearchSort.Relevance ? `${sortKey}:${sortOrd ?? "asc"}` : undefined, - }, -}); - -export const SearchPage: QueryPage<{ q?: string }> = ({ q }) => { - const pageStyle = usePageStyle(); - const { t } = useTranslation(); - const [sort, setSort] = useParam("sortBy"); - const [mediaTypeParam, setMediaTypeParam] = useParam("mediaType"); - const sortKey = (sort?.split(":")[0] as SearchSort) || SearchSort.Relevance; - const sortOrd = (sort?.split(":")[1] as SortOrd) || SortOrd.Asc; - const [layout, setLayout] = useState(Layout.Grid); - - const mediaType = getMediaTypeFromParam(mediaTypeParam); - const LayoutComponent = layout === Layout.Grid ? ItemGrid : ItemList; - - return ( - { - setSort(`${key}:${ord}`); - }} - mediaType={mediaType} - availableMediaTypes={MediaTypes} - setMediaType={(mediaType) => { - setMediaTypeParam(mediaType.key); - }} - layout={layout} - setLayout={setLayout} - /> - } - contentContainerStyle={pageStyle} - Render={({ item }) => } - Loader={LayoutComponent.Loader} - /> - ); -}; - -SearchPage.getLayout = DefaultLayout; -SearchPage.getFetchUrls = ({ q, sortBy, mediaType }) => { - const mediaTypeObj = getMediaTypeFromParam(mediaType); - return [ - query(mediaTypeObj, q, sortBy?.split("-")[0] as SearchSort, sortBy?.split("-")[1] as SortOrd), - ]; -}; diff --git a/front/src/ui/browse/index.tsx b/front/src/ui/browse/index.tsx index d438754c..5b126676 100644 --- a/front/src/ui/browse/index.tsx +++ b/front/src/ui/browse/index.tsx @@ -8,6 +8,7 @@ import type { SortBy, SortOrd } from "./types"; export const BrowsePage = () => { const [filter, setFilter] = useQueryState("filter", ""); const [sort, setSort] = useQueryState("sort", "name"); + const [search] = useQueryState("q", ""); const sortOrd = sort.startsWith("-") ? "desc" : "asc"; const sortBy = (sort.startsWith("-") ? sort.substring(1) : sort) as SortBy; @@ -17,7 +18,7 @@ export const BrowsePage = () => { return ( { ); }; -BrowsePage.query = ( - filter?: string, - sortBy?: SortBy, - sortOrd?: SortOrd, -): QueryIdentifier => { +BrowsePage.query = ({ + filter, + sortBy, + sortOrd, + search, +}: { + filter?: string; + sortBy?: SortBy; + sortOrd?: SortOrd; + search?: string; +}): QueryIdentifier => { return { parser: Show, path: ["api", "shows"], @@ -50,6 +57,7 @@ BrowsePage.query = ( params: { sort: sortBy ? `${sortOrd === "desc" ? "-" : ""}${sortBy}` : "name", filter, + query: search, }, }; }; diff --git a/front/src/ui/navbar/index.tsx b/front/src/ui/navbar/index.tsx index f8655f80..468a30a0 100644 --- a/front/src/ui/navbar/index.tsx +++ b/front/src/ui/navbar/index.tsx @@ -4,7 +4,8 @@ import Login from "@material-symbols/svg-400/rounded/login.svg"; import Logout from "@material-symbols/svg-400/rounded/logout.svg"; import Search from "@material-symbols/svg-400/rounded/search-fill.svg"; import Settings from "@material-symbols/svg-400/rounded/settings.svg"; -import type { Ref } from "react"; +import { useGlobalSearchParams, usePathname, useRouter } from "expo-router"; +import { type Ref, useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { Platform, @@ -28,7 +29,6 @@ import { } from "~/primitives"; import { useAccount, useAccounts } from "~/providers/account-context"; import { logout } from "~/ui/login/logic"; -import { useQueryState } from "~/utils"; import { KyooLongLogo } from "./icon"; export const NavbarTitle = (props: { onLayout?: ViewProps["onLayout"] }) => { @@ -52,13 +52,31 @@ const SearchBar = ({ }: TextInputProps & { ref?: Ref }) => { const { theme } = useYoshiki(); const { t } = useTranslation(); - const [query, setQuery] = useQueryState("q", ""); + const params = useGlobalSearchParams(); + const [query, setQuery] = useState((params.q as string) ?? ""); + const path = usePathname(); + const router = useRouter(); + const inputRef = useRef(null); + + useEffect(() => { + if (path === "/browse") { + inputRef.current?.focus(); + setQuery(params.q as string); + } else { + inputRef.current?.blur(); + setQuery(""); + } + }, [path, params.q]); return ( { + setQuery(q); + if (path !== "/browse") router.navigate(`/browse?q=${q}`); + else router.setParams({ q }); + }} placeholder={t("navbar.search")} placeholderTextColor={theme.contrast} containerStyle={{ @@ -153,7 +171,7 @@ export const NavbarRight = () => { icon={Search} color={theme.colors.white} as={Link} - href={"/search"} + href={"/browse"} {...tooltip(t("navbar.search"))} /> )} diff --git a/front/src/utils.ts b/front/src/utils.ts index 2d67999c..fc93627d 100644 --- a/front/src/utils.ts +++ b/front/src/utils.ts @@ -1,5 +1,5 @@ -import { NavigationContext, useRoute } from "@react-navigation/native"; -import { useCallback, useContext } from "react"; +import { useLocalSearchParams, useRouter } from "expo-router"; +import { useCallback } from "react"; import type { Movie, Show } from "~/models"; export function setServerData(_key: string, _val: any) {} @@ -8,15 +8,15 @@ export function getServerData(key: string) { } export const useQueryState = (key: string, initial: S) => { - const route = useRoute(); - const nav = useContext(NavigationContext); + const params = useLocalSearchParams(); + const router = useRouter(); - const state = ((route.params as any)?.[key] as S) ?? initial; + const state = (params[key] as S) ?? initial; const update = useCallback( (val: S | ((old: S) => S)) => { - nav!.setParams({ [key]: val }); + router.setParams({ [key]: val } as any); }, - [nav, key], + [router, key], ); return [state, update] as const; };