|
@@ -1,9 +1,9 @@
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
|
|
import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
|
|
|
|
|
|
|
|
-
|
|
|
|
|
import { IExternalAccount } from '~/interfaces/external-account';
|
|
import { IExternalAccount } from '~/interfaces/external-account';
|
|
|
import { IUser } from '~/interfaces/user';
|
|
import { IUser } from '~/interfaces/user';
|
|
|
|
|
+import { useCurrentUser } from '~/stores/context';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import { apiv3Get, apiv3Put } from '../client/util/apiv3-client';
|
|
import { apiv3Get, apiv3Put } from '../client/util/apiv3-client';
|
|
@@ -14,8 +14,12 @@ const logger = loggerFactory('growi:stores:personal-settings');
|
|
|
|
|
|
|
|
|
|
|
|
|
export const useSWRxPersonalSettings = (config?: SWRConfiguration): SWRResponse<IUser, Error> => {
|
|
export const useSWRxPersonalSettings = (config?: SWRConfiguration): SWRResponse<IUser, Error> => {
|
|
|
|
|
+ const { data: currrentUser } = useCurrentUser();
|
|
|
|
|
+
|
|
|
|
|
+ const key = currrentUser != null ? '/personal-setting' : null;
|
|
|
|
|
+
|
|
|
return useSWR(
|
|
return useSWR(
|
|
|
- '/personal-setting',
|
|
|
|
|
|
|
+ key,
|
|
|
endpoint => apiv3Get(endpoint).then(response => response.data.currentUser),
|
|
endpoint => apiv3Get(endpoint).then(response => response.data.currentUser),
|
|
|
config,
|
|
config,
|
|
|
);
|
|
);
|