quick fix noop context
This commit is contained in:
@@ -13,11 +13,39 @@ export const useSpotify = (): SpotifyContextType => {
|
||||
};
|
||||
|
||||
export const useSpotifyAuth = () => {
|
||||
const { isAuthenticated, login, logout } = useSpotify();
|
||||
const context = useSpotify();
|
||||
|
||||
if (!context) {
|
||||
return {
|
||||
isAuthenticated: false,
|
||||
login: async () => {},
|
||||
logout: async () => {},
|
||||
};
|
||||
}
|
||||
|
||||
const { isAuthenticated, login, logout } = context;
|
||||
return { isAuthenticated, login, logout };
|
||||
};
|
||||
|
||||
export const useSpotifyPlayback = () => {
|
||||
const context = useSpotify();
|
||||
|
||||
if (!context) {
|
||||
return {
|
||||
playbackState: null,
|
||||
currentTrack: null,
|
||||
play: async () => {},
|
||||
playTrack: async () => {},
|
||||
pause: async () => {},
|
||||
skipNext: async () => {},
|
||||
skipPrevious: async () => {},
|
||||
setVolume: async () => {},
|
||||
refreshPlaybackState: async () => {},
|
||||
isLoading: false,
|
||||
isPlaying: false,
|
||||
};
|
||||
}
|
||||
|
||||
const {
|
||||
playbackState,
|
||||
currentTrack,
|
||||
@@ -29,7 +57,7 @@ export const useSpotifyPlayback = () => {
|
||||
setVolume,
|
||||
refreshPlaybackState,
|
||||
isLoading,
|
||||
} = useSpotify();
|
||||
} = context;
|
||||
|
||||
return {
|
||||
playbackState,
|
||||
@@ -47,14 +75,26 @@ export const useSpotifyPlayback = () => {
|
||||
};
|
||||
|
||||
export const useSpotifyDevices = () => {
|
||||
const context = useSpotify();
|
||||
|
||||
if (!context) {
|
||||
return {
|
||||
devices: [],
|
||||
activeDevice: null,
|
||||
getDevices: async () => {},
|
||||
setActiveDevice: async () => {},
|
||||
isLoading: false,
|
||||
};
|
||||
}
|
||||
|
||||
const {
|
||||
devices,
|
||||
activeDevice,
|
||||
getDevices,
|
||||
setActiveDevice,
|
||||
isLoading,
|
||||
} = useSpotify();
|
||||
|
||||
} = context;
|
||||
|
||||
return {
|
||||
devices,
|
||||
activeDevice,
|
||||
|
||||
Reference in New Issue
Block a user