Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): currentUser undefined when all workspaces deleted (#4812)

EYHN1d7e3dd5706c
diff --git a/packages/frontend/workspace/src/affine/gql.ts b/packages/frontend/workspace/src/affine/gql.ts
index 6a6a30b738..102e5c7d31 100644
--- a/packages/frontend/workspace/src/affine/gql.ts
+++ b/packages/frontend/workspace/src/affine/gql.ts
@@ -8,6 +8,7 @@ import type {
} from '@affine/graphql';
import { gqlFetcherFactory } from '@affine/graphql';
import type { GraphQLError } from 'graphql';
+import { useMemo } from 'react';
import type { Key, SWRConfiguration, SWRResponse } from 'swr';
import useSWR from 'swr';
import type {
@@ -70,10 +71,18 @@ export function useQuery<Query extends GraphQLQuery>(
options: QueryOptions<Query>,
config?: any
) {
+ const configWithSuspense: SWRConfiguration = useMemo(
+ () => ({
+ suspense: true,
+ ...config,
+ }),
+ [config]
+ );
+
return useSWR(
() => ['cloud', options.query.id, options.variables],
() => fetcher(options),
- config
+ configWithSuspense
);
}