mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
feat: impl unlimited features (#5659)
This commit is contained in:
@@ -22,7 +22,7 @@ import { useInviteMember } from '@affine/core/hooks/affine/use-invite-member';
|
||||
import { useMemberCount } from '@affine/core/hooks/affine/use-member-count';
|
||||
import { type Member, useMembers } from '@affine/core/hooks/affine/use-members';
|
||||
import { useRevokeMemberPermission } from '@affine/core/hooks/affine/use-revoke-member-permission';
|
||||
import { useUserQuota } from '@affine/core/hooks/use-quota';
|
||||
import { useWorkspaceQuota } from '@affine/core/hooks/use-quota';
|
||||
import { useUserSubscription } from '@affine/core/hooks/use-subscription';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { Permission, SubscriptionPlan } from '@affine/graphql';
|
||||
@@ -77,7 +77,7 @@ export const CloudWorkspaceMembersPanel = ({
|
||||
[]
|
||||
);
|
||||
|
||||
const quota = useUserQuota();
|
||||
const quota = useWorkspaceQuota(workspaceId);
|
||||
const [subscription] = useUserSubscription();
|
||||
const plan = subscription?.plan ?? SubscriptionPlan.Free;
|
||||
const isLimited = checkMemberCountLimit(memberCount, quota?.memberLimit);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { quotaQuery } from '@affine/graphql';
|
||||
import { quotaQuery, workspaceQuotaQuery } from '@affine/graphql';
|
||||
|
||||
import { useQuery } from './use-query';
|
||||
|
||||
@@ -9,3 +9,14 @@ export const useUserQuota = () => {
|
||||
|
||||
return data.currentUser?.quota || null;
|
||||
};
|
||||
|
||||
export const useWorkspaceQuota = (id: string) => {
|
||||
const { data } = useQuery({
|
||||
query: workspaceQuotaQuery,
|
||||
variables: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
return data.workspace?.quota || null;
|
||||
};
|
||||
|
||||
@@ -17,24 +17,18 @@ export const useWorkspaceQuota = (workspaceId: string) => {
|
||||
}, []);
|
||||
|
||||
const quotaData = data.workspace.quota;
|
||||
const blobLimit = BigInt(quotaData.blobLimit);
|
||||
const storageQuota = BigInt(quotaData.storageQuota);
|
||||
const usedSize = BigInt(quotaData.usedSize);
|
||||
|
||||
const humanReadableBlobLimit = changeToHumanReadable(blobLimit.toString());
|
||||
const humanReadableStorageQuota = changeToHumanReadable(
|
||||
storageQuota.toString()
|
||||
const humanReadableUsedSize = changeToHumanReadable(
|
||||
quotaData.usedSize.toString()
|
||||
);
|
||||
const humanReadableUsedSize = changeToHumanReadable(usedSize.toString());
|
||||
|
||||
return {
|
||||
blobLimit,
|
||||
storageQuota,
|
||||
usedSize,
|
||||
blobLimit: quotaData.blobLimit,
|
||||
storageQuota: quotaData.storageQuota,
|
||||
usedSize: quotaData.usedSize,
|
||||
humanReadable: {
|
||||
name: quotaData.humanReadableName,
|
||||
blobLimit: humanReadableBlobLimit,
|
||||
storageQuota: humanReadableStorageQuota,
|
||||
name: quotaData.humanReadable.name,
|
||||
blobLimit: quotaData.humanReadable.blobLimit,
|
||||
storageQuota: quotaData.humanReadable.storageQuota,
|
||||
usedSize: humanReadableUsedSize,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user