feat: impl unlimited features (#5659)

This commit is contained in:
DarkSky
2024-01-26 08:28:53 +00:00
parent 04b9029d1b
commit 070d5ca471
13 changed files with 177 additions and 62 deletions

View File

@@ -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;
};

View File

@@ -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,
},
};