From 11965dd513b75c1c1b703e343d9d2322afa93990 Mon Sep 17 00:00:00 2001 From: Violet Caulfield Date: Sat, 15 Feb 2025 06:22:14 -0600 Subject: [PATCH] more memory optimizations --- api/queries.ts | 2 -- api/queries/libraries.ts | 30 --------------------- components/Home/helpers/recently-played.tsx | 17 +++++++----- components/Login/screens/server-library.tsx | 9 +++++-- 4 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 api/queries/libraries.ts diff --git a/api/queries.ts b/api/queries.ts index 328582bd..65bf3c66 100644 --- a/api/queries.ts +++ b/api/queries.ts @@ -13,6 +13,4 @@ export const useApi = (serverUrl?: string, username?: string, password?: string, return createApi(serverUrl, username, password, accessToken) }, - gcTime: 1000, - refetchInterval: false }) \ No newline at end of file diff --git a/api/queries/libraries.ts b/api/queries/libraries.ts deleted file mode 100644 index d2fd5b8a..00000000 --- a/api/queries/libraries.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { QueryKeys } from "../../enums/query-keys"; -import { useQuery } from "@tanstack/react-query"; -import { fetchMusicLibraries, fetchPlaylistLibrary, fetchUserViews } from "./functions/libraries"; - -/** - * @deprecated use {@link useUserViews} instead as that will respect user permissions - * @returns - */ -export const useMusicLibraries = () => useQuery({ - queryKey: [QueryKeys.Libraries], - queryFn: () => fetchMusicLibraries() -}); - -/** - * @deprecated use {@link useUserViews} instead as that will respect user permissions - * @returns - */ -export const usePlaylistLibrary = () => useQuery({ - queryKey: [QueryKeys.Playlist], - queryFn: () => fetchPlaylistLibrary() -}); - -/** - * - * @returns - */ -export const useUserViews = () => useQuery({ - queryKey: [QueryKeys.UserViews], - queryFn: () => fetchUserViews() -}); \ No newline at end of file diff --git a/components/Home/helpers/recently-played.tsx b/components/Home/helpers/recently-played.tsx index 19ae4fc5..c5615bc2 100644 --- a/components/Home/helpers/recently-played.tsx +++ b/components/Home/helpers/recently-played.tsx @@ -9,6 +9,7 @@ import { NativeStackNavigationProp } from "@react-navigation/native-stack"; import { trigger } from "react-native-haptic-feedback"; import { QueuingType } from "../../../enums/queuing-type"; import Icon from "../../../components/Global/helpers/icon"; +import { FlatList } from "react-native"; export default function RecentlyPlayed({ navigation @@ -42,11 +43,10 @@ export default function RecentlyPlayed({ )} - - { recentTracks && recentTracks.map((recentlyPlayedTrack, index) => { + data={recentTracks} + renderItem={({ index, item: recentlyPlayedTrack }) => { return ( ) - })} - + }} + style={{ + overflow: 'hidden' + }} + /> ) } \ No newline at end of file diff --git a/components/Login/screens/server-library.tsx b/components/Login/screens/server-library.tsx index a3e0876a..900400d8 100644 --- a/components/Login/screens/server-library.tsx +++ b/components/Login/screens/server-library.tsx @@ -4,11 +4,13 @@ import { useAuthenticationContext } from "../provider"; import { H1, H2, Label, Text } from "../../Global/helpers/text"; import Button from "../../Global/helpers/button"; import _ from "lodash"; -import { useUserViews } from "../../../api/queries/libraries"; import { SafeAreaView } from "react-native-safe-area-context"; import Client from "../../../api/client"; import { useJellifyContext } from "../../provider"; import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; +import { QueryKeys } from "../../../enums/query-keys"; +import { fetchUserViews } from "../../../api/queries/functions/libraries"; +import { useQuery } from "@tanstack/react-query"; export default function ServerLibrary(): React.JSX.Element { @@ -19,7 +21,10 @@ export default function ServerLibrary(): React.JSX.Element { const [libraryId, setLibraryId] = useState(undefined); const [playlistLibrary, setPlaylistLibrary] = useState(undefined); - const { data : libraries, isError, isPending, isSuccess, refetch } = useUserViews(); + const { data : libraries, isError, isPending, isSuccess, refetch } = useQuery({ + queryKey: [QueryKeys.UserViews], + queryFn: () => fetchUserViews() + });; useEffect(() => { if (!isPending && isSuccess)