mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 20:40:21 +02:00
add isAdmin to auth state
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user