quick fix noop context

This commit is contained in:
yohlo
2025-10-06 12:34:58 -05:00
parent b2df869111
commit 42bd2542f3
3 changed files with 48 additions and 6 deletions

View File

@@ -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,