Yuki Takei 7 ماه پیش
والد
کامیت
8c1dbeb50c

+ 2 - 2
apps/app/src/client/components/Navbar/GrowiNavbarBottom.tsx

@@ -14,8 +14,8 @@ export const GrowiNavbarBottom = (): JSX.Element => {
 
   const [isDrawerOpened, setIsDrawerOpened] = useDrawerOpened();
   const { open: openCreateModal } = usePageCreateModal();
-  const [currentPagePath] = useCurrentPagePath();
-  const [isSearchPage] = useIsSearchPage();
+  const currentPagePath = useCurrentPagePath();
+  const isSearchPage = useIsSearchPage();
   const { open: openSearchModal } = useSearchModal();
 
   const searchButtonClickHandler = useCallback(() => {

+ 4 - 3
apps/app/src/client/components/PageRenameModal.tsx

@@ -4,6 +4,7 @@ import React, {
 
 import { isIPageInfoForEntity } from '@growi/core';
 import { pagePathUtils } from '@growi/core/dist/utils';
+import { useAtomValue } from 'jotai';
 import { useTranslation } from 'next-i18next';
 import {
   Collapse, Modal, ModalHeader, ModalBody, ModalFooter,
@@ -13,7 +14,7 @@ import { debounce } from 'throttle-debounce';
 import { apiv3Get, apiv3Put } from '~/client/util/apiv3-client';
 import { toastError } from '~/client/util/toastr';
 import { useSiteUrl } from '~/states/global';
-import { useIsSearchServiceReachable } from '~/states/server-configurations';
+import { isSearchServiceReachableAtom } from '~/states/server-configurations';
 import { usePageRenameModal } from '~/stores/modal';
 import { useSWRxPageInfo } from '~/stores/page';
 
@@ -30,9 +31,9 @@ const PageRenameModal = (): JSX.Element => {
   const { t } = useTranslation();
 
   const { isUsersHomepage } = pagePathUtils;
-  const [siteUrl] = useSiteUrl();
+  const siteUrl = useSiteUrl();
   const { data: renameModalData, close: closeRenameModal } = usePageRenameModal();
-  const [isReachable] = useIsSearchServiceReachable();
+  const isReachable = useAtomValue(isSearchServiceReachableAtom);
 
   const isOpened = renameModalData?.isOpened ?? false;
   const page = renameModalData?.page;

+ 4 - 4
apps/app/src/client/components/PageStatusAlert.tsx

@@ -16,12 +16,12 @@ export const PageStatusAlert = (): JSX.Element => {
   const { t } = useTranslation();
 
   const { editorMode } = useEditorMode();
-  const [isGuestUser] = useIsGuestUser();
-  const [isReadOnlyUser] = useIsReadOnlyUser();
+  const isGuestUser = useIsGuestUser();
+  const isReadOnlyUser = useIsReadOnlyUser();
   const { data: pageStatusAlertData } = usePageStatusAlert();
-  const [remoteRevisionId] = useRemoteRevisionId();
+  const remoteRevisionId = useRemoteRevisionId();
   const { data: remoteRevisionLastUpdateUser } = useRemoteRevisionLastUpdateUser();
-  const [pageData] = useCurrentPageData();
+  const pageData = useCurrentPageData();
 
   const onClickRefreshPage = useCallback(() => {
     pageStatusAlertData?.onRefleshPage?.();

+ 6 - 7
apps/app/src/client/components/SearchPage/SearchPageBase.tsx

@@ -4,6 +4,7 @@ import React, {
 } from 'react';
 
 import { LoadingSpinner } from '@growi/ui/dist/components';
+import { useAtomValue } from 'jotai';
 import { useTranslation } from 'next-i18next';
 import dynamic from 'next/dynamic';
 
@@ -12,9 +13,7 @@ import { toastSuccess } from '~/client/util/toastr';
 import type { IFormattedSearchResult, IPageWithSearchMeta } from '~/interfaces/search';
 import type { OnDeletedFunction } from '~/interfaces/ui';
 import { useIsGuestUser, useIsReadOnlyUser } from '~/states/context';
-import {
-  useIsSearchServiceConfigured, useIsSearchServiceReachable,
-} from '~/states/server-configurations';
+import { isSearchServiceConfiguredAtom, isSearchServiceReachableAtom } from '~/states/server-configurations';
 import { usePageDeleteModal } from '~/stores/modal';
 import { mutatePageTree, mutateRecentlyUpdated } from '~/stores/page-listing';
 
@@ -66,10 +65,10 @@ const SearchPageBaseSubstance: ForwardRefRenderFunction<ISelectableAll & IReturn
 
   const searchResultListRef = useRef<ISelectableAll|null>(null);
 
-  const [isGuestUser] = useIsGuestUser();
-  const [isReadOnlyUser] = useIsReadOnlyUser();
-  const [isSearchServiceConfigured] = useIsSearchServiceConfigured();
-  const [isSearchServiceReachable] = useIsSearchServiceReachable();
+  const isGuestUser = useIsGuestUser();
+  const isReadOnlyUser = useIsReadOnlyUser();
+  const isSearchServiceConfigured = useAtomValue(isSearchServiceConfiguredAtom);
+  const isSearchServiceReachable = useAtomValue(isSearchServiceReachableAtom);
 
   const [selectedPageIdsByCheckboxes] = useState<Set<string>>(new Set());
   // const [allPageIds] = useState<Set<string>>(new Set());

+ 1 - 1
apps/app/src/pages/admin/ai-integration.page.tsx

@@ -3,7 +3,7 @@ import type { GetServerSideProps } from 'next';
 import dynamic from 'next/dynamic';
 
 import type { CrowiRequest } from '~/interfaces/crowi-request';
-import { aiEnabledAtom } from '~/states/server-configurations/server-configurations';
+import { aiEnabledAtom } from '~/states/server-configurations';
 
 import type { NextPageWithLayout } from '../_app.page';
 import { mergeGetServerSidePropsResults } from '../utils/server-side-props';

+ 1 - 1
apps/app/src/stores/bookmark.ts

@@ -28,7 +28,7 @@ export const useSWRxUserBookmarks = (userId: string | null): SWRResponse<(IPageH
 };
 
 export const useSWRMUTxCurrentUserBookmarks = (): SWRMutationResponse<(IPageHasId | null)[], Error> => {
-  const [currentUser] = useCurrentUser();
+  const currentUser = useCurrentUser();
 
   return useSWRMutation(
     currentUser != null ? `/bookmarks/${currentUser?._id}` : null,

+ 2 - 2
apps/app/src/stores/yjs.ts

@@ -15,7 +15,7 @@ type CurrentPageYjsDataUtils = {
 }
 
 export const useCurrentPageYjsData = (): SWRResponse<CurrentPageYjsData, Error> & CurrentPageYjsDataUtils => {
-  const [currentPageId] = useCurrentPageId();
+  const currentPageId = useCurrentPageId();
 
   const key = currentPageId != null
     ? `/page/${currentPageId}/yjs-data`
@@ -35,7 +35,7 @@ export const useCurrentPageYjsData = (): SWRResponse<CurrentPageYjsData, Error>
 };
 
 export const useSWRMUTxCurrentPageYjsData = (): SWRMutationResponse<CurrentPageYjsData, Error> => {
-  const [currentPageId] = useCurrentPageId();
+  const currentPageId = useCurrentPageId();
 
   const key = currentPageId != null
     ? `/page/${currentPageId}/yjs-data`