mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
feat: impl unlimited features (#5659)
This commit is contained in:
@@ -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