mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 16:19:43 +08:00
chore(admin): organize massive routes (#7857)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { useMutateQueryResource } from '@affine/core/hooks/use-mutation';
|
||||
import { useQueryImmutable } from '@affine/core/hooks/use-query';
|
||||
import type { GetCurrentUserFeaturesQuery } from '@affine/graphql';
|
||||
import {
|
||||
adminServerConfigQuery,
|
||||
FeatureType,
|
||||
getCurrentUserFeaturesQuery,
|
||||
} from '@affine/graphql';
|
||||
|
||||
@@ -12,10 +15,22 @@ export const useServerConfig = () => {
|
||||
return data.serverConfig;
|
||||
};
|
||||
|
||||
export const useRevalidateCurrentUser = () => {
|
||||
const revalidate = useMutateQueryResource();
|
||||
|
||||
return () => {
|
||||
revalidate(getCurrentUserFeaturesQuery);
|
||||
};
|
||||
};
|
||||
export const useCurrentUser = () => {
|
||||
const { data } = useQueryImmutable({
|
||||
query: getCurrentUserFeaturesQuery,
|
||||
});
|
||||
|
||||
return data.currentUser;
|
||||
};
|
||||
|
||||
export function isAdmin(
|
||||
user: NonNullable<GetCurrentUserFeaturesQuery['currentUser']>
|
||||
) {
|
||||
return user.features.includes(FeatureType.Admin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user