mirror of
https://github.com/Jellify-Music/App.git
synced 2026-03-15 08:29:54 -05:00
going back to this
This commit is contained in:
@@ -7,11 +7,14 @@ import _ from "lodash";
|
||||
import { useMusicLibraries, usePlaylistLibrary } from "../../../api/queries/libraries";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import Client from "../../../api/client";
|
||||
import { useJellifyContext } from "@/components/provider";
|
||||
|
||||
export default function ServerLibrary(): React.JSX.Element {
|
||||
|
||||
const { setUser } = useAuthenticationContext();
|
||||
|
||||
const { setLoggedIn } = useJellifyContext();
|
||||
|
||||
const [libraryId, setLibraryId] = useState<string | undefined>(undefined);
|
||||
|
||||
const { data : libraries, isError, isPending, refetch: refetchMusicLibraries } = useMusicLibraries();
|
||||
@@ -54,6 +57,7 @@ export default function ServerLibrary(): React.JSX.Element {
|
||||
playlistLibraryId: playlistLibrary!.Id!,
|
||||
playlistLibraryPrimaryImageId: playlistLibrary!.ImageTags!.Primary,
|
||||
});
|
||||
setLoggedIn(true);
|
||||
}}>
|
||||
Let's Go!
|
||||
</Button>
|
||||
|
||||
@@ -2,12 +2,16 @@ import React from "react";
|
||||
import Button from "../../Global/helpers/button";
|
||||
import { stop } from "react-native-track-player/lib/src/trackPlayer";
|
||||
import Client from "../../../api/client";
|
||||
import { useJellifyContext } from "@/components/provider";
|
||||
|
||||
export default function SignOut(): React.JSX.Element {
|
||||
|
||||
const { setLoggedIn } = useJellifyContext();
|
||||
|
||||
return (
|
||||
<Button onPress={() => {
|
||||
stop();
|
||||
setLoggedIn(false);
|
||||
Client.signOut();
|
||||
}}>
|
||||
Sign Out
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import Client from "../api/client";
|
||||
import { isUndefined } from "lodash";
|
||||
import { createContext, ReactNode, useContext, useEffect, useState } from "react";
|
||||
import { createContext, ReactNode, SetStateAction, useContext, useEffect, useState } from "react";
|
||||
import { CarPlay } from "react-native-carplay";
|
||||
import CarPlayNavigation from "./CarPlay/Navigation";
|
||||
import CarPlayNowPlaying from "./CarPlay/NowPlaying";
|
||||
|
||||
interface JellifyContext {
|
||||
loggedIn: boolean;
|
||||
setLoggedIn: React.Dispatch<SetStateAction<boolean>>;
|
||||
carPlayConnected: boolean;
|
||||
}
|
||||
|
||||
@@ -15,23 +14,10 @@ const JellifyContextInitializer = () => {
|
||||
const [loggedIn, setLoggedIn] = useState<boolean>(
|
||||
!isUndefined(Client.api) &&
|
||||
!isUndefined(Client.user) &&
|
||||
!isUndefined(Client.server)
|
||||
!isUndefined(Client.server) &&
|
||||
!isUndefined(Client.library)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setLoggedIn(
|
||||
!isUndefined(Client.api) &&
|
||||
!isUndefined(Client.user) &&
|
||||
!isUndefined(Client.server) &&
|
||||
!isUndefined(Client.library)
|
||||
)
|
||||
}, [
|
||||
Client.api,
|
||||
Client.user,
|
||||
Client.library,
|
||||
Client.server,
|
||||
]);
|
||||
|
||||
|
||||
const [carPlayConnected, setCarPlayConnected] = useState(CarPlay.connected);
|
||||
|
||||
@@ -57,12 +43,14 @@ const JellifyContextInitializer = () => {
|
||||
|
||||
return {
|
||||
loggedIn,
|
||||
setLoggedIn,
|
||||
carPlayConnected
|
||||
}
|
||||
}
|
||||
|
||||
const JellifyContext = createContext<JellifyContext>({
|
||||
loggedIn: false,
|
||||
setLoggedIn: () => {},
|
||||
carPlayConnected: false
|
||||
});
|
||||
|
||||
@@ -71,6 +59,7 @@ export const JellifyProvider: ({ children }: {
|
||||
}) => React.JSX.Element = ({ children }: { children: ReactNode }) => {
|
||||
const {
|
||||
loggedIn,
|
||||
setLoggedIn,
|
||||
carPlayConnected
|
||||
} = JellifyContextInitializer();
|
||||
|
||||
@@ -78,6 +67,7 @@ export const JellifyProvider: ({ children }: {
|
||||
<JellifyContext.Provider
|
||||
value={{
|
||||
loggedIn,
|
||||
setLoggedIn,
|
||||
carPlayConnected
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user