fix(core): currentUser undefined when all workspaces deleted (#4812)
This commit is contained in:
@@ -8,6 +8,7 @@ import type {
|
|||||||
} from '@affine/graphql';
|
} from '@affine/graphql';
|
||||||
import { gqlFetcherFactory } from '@affine/graphql';
|
import { gqlFetcherFactory } from '@affine/graphql';
|
||||||
import type { GraphQLError } from 'graphql';
|
import type { GraphQLError } from 'graphql';
|
||||||
|
import { useMemo } from 'react';
|
||||||
import type { Key, SWRConfiguration, SWRResponse } from 'swr';
|
import type { Key, SWRConfiguration, SWRResponse } from 'swr';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import type {
|
import type {
|
||||||
@@ -70,10 +71,18 @@ export function useQuery<Query extends GraphQLQuery>(
|
|||||||
options: QueryOptions<Query>,
|
options: QueryOptions<Query>,
|
||||||
config?: any
|
config?: any
|
||||||
) {
|
) {
|
||||||
|
const configWithSuspense: SWRConfiguration = useMemo(
|
||||||
|
() => ({
|
||||||
|
suspense: true,
|
||||||
|
...config,
|
||||||
|
}),
|
||||||
|
[config]
|
||||||
|
);
|
||||||
|
|
||||||
return useSWR(
|
return useSWR(
|
||||||
() => ['cloud', options.query.id, options.variables],
|
() => ['cloud', options.query.id, options.variables],
|
||||||
() => fetcher(options),
|
() => fetcher(options),
|
||||||
config
|
configWithSuspense
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user