add isAdmin to auth state

This commit is contained in:
jeffvli
2025-12-07 17:21:46 -08:00
parent 2f2dbbde3e
commit 4ddada1fe3
10 changed files with 51 additions and 3 deletions
+20
View File
@@ -120,6 +120,7 @@ export const useCurrentServer = () =>
return {
features: state.currentServer?.features,
id: state.currentServer?.id,
isAdmin: state.currentServer?.isAdmin,
musicFolderId: state.currentServer?.musicFolderId,
name: state.currentServer?.name,
preferInstantMix: state.currentServer?.preferInstantMix,
@@ -132,6 +133,14 @@ export const useCurrentServer = () =>
};
}, shallow) as ServerListItem;
export const useIsAdmin = () =>
useAuthStore((state) => {
return {
isAdmin: state.currentServer?.isAdmin ?? false,
userId: state.currentServer?.userId,
};
}, shallow);
export const useCurrentServerWithCredential = () =>
useAuthStore((state) => state.currentServer) as ServerListItemWithCredential;
@@ -146,3 +155,14 @@ export const getServerById = (id?: string) => {
return useAuthStore.getState().actions.getServer(id);
};
export const usePermissions = () => {
const { isAdmin, userId } = useIsAdmin();
return {
playlists: {
editPublic: isAdmin,
},
userId: userId,
};
};