Yuki Takei 8 месяцев назад
Родитель
Сommit
7005b536cc

+ 2 - 2
apps/app/src/pages/[[...path]].page.tsx

@@ -24,7 +24,7 @@ import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
 import { useEditorModeClassName } from '~/services/layout/use-editor-mode-class-name';
 import { useHydrateSidebarAtoms } from '~/states/hydrate/sidebar';
 import {
-  useCurrentPageData, useFetchCurrentPage, useCurrentPageId, useCurrentPagePath, usePageNotFound, usePageNotCreatable,
+  useCurrentPageData, useFetchCurrentPage, useCurrentPageId, useCurrentPagePath, usePageNotFound,
 } from '~/states/page';
 import { useHydratePageAtoms } from '~/states/page/hydrate';
 import {
@@ -231,7 +231,7 @@ type LayoutProps = Props & {
 
 const Layout = ({ children, ...props }: LayoutProps): JSX.Element => {
   // Hydrate sidebar atoms with server-side data - must be called unconditionally
-  const sidebarConfig = isInitialProps(props) ? props.sidebarConfig : { isSidebarCollapsedMode: false };
+  const sidebarConfig = isInitialProps(props) ? props.sidebarConfig : undefined;
   const userUISettings = isInitialProps(props) ? props.userUISettings : undefined;
   useHydrateSidebarAtoms(sidebarConfig, userUISettings);
 

+ 1 - 1
apps/app/src/pages/[[...path]]/page-data-injectors.ts

@@ -5,7 +5,7 @@ import type { CrowiRequest } from '~/interfaces/crowi-request';
 import type { PageModel, PageDocument } from '~/server/models/page';
 import type { PageRedirectModel } from '~/server/models/page-redirect';
 
-import type { ExtendedInitialProps, SameRouteEachProps } from './types.js';
+import type { ExtendedInitialProps, SameRouteEachProps } from './types';
 
 const { isPermalink: _isPermalink, isCreatablePage } = pagePathUtils;
 const { removeHeadingSlash } = pathUtils;

+ 7 - 7
apps/app/src/pages/[[...path]]/server-side-props.ts

@@ -8,10 +8,10 @@ import { getServerSidePageTitleCustomizationProps } from '~/pages/utils/page-tit
 import { getServerSideSSRProps } from '~/pages/utils/ssr';
 import { getServerSideUserUISettingsProps } from '~/pages/utils/user-ui-settings';
 
-import { getServerSideConfigurationProps } from './configuration-props.js';
-import { injectPageDataForInitial, injectSameRoutePageData } from './page-data-injectors.js';
-import type { InitialProps, SameRouteEachProps } from './types.js';
-import { getAction } from './utils.js';
+import { getServerSideConfigurationProps } from './configuration-props';
+import { injectPageDataForInitial, injectSameRoutePageData } from './page-data-injectors';
+import type { InitialProps, SameRouteEachProps } from './types';
+import { getAction } from './utils';
 
 const NEXT_JS_ROUTING_PAGE = '[[...path]]';
 
@@ -24,12 +24,12 @@ async function createNextI18NextConfig(context: GetServerSidePropsContext, names
 }
 
 // Common props collection helper
-async function collectProps(context: GetServerSidePropsContext, includeConfiguration = true) {
+async function collectProps(context: GetServerSidePropsContext) {
   const propResults = await Promise.all([
     getServerSideCommonInitialProps(context),
     getServerSidePageTitleCustomizationProps(context),
     getServerSideUserUISettingsProps(context),
-    ...(includeConfiguration ? [getServerSideConfigurationProps(context)] : []),
+    getServerSideConfigurationProps(context),
   ]);
 
   // Validate all results have props
@@ -68,7 +68,7 @@ function handleUserAndRedirects(context: GetServerSidePropsContext, props: Recor
 }
 export async function getServerSidePropsForInitial(context: GetServerSidePropsContext): Promise<GetServerSidePropsResult<InitialProps & SameRouteEachProps>> {
   // Collect all required props
-  const collectedProps = await collectProps(context, true);
+  const collectedProps = await collectProps(context);
 
   const props: InitialProps & SameRouteEachProps = {
     ...collectedProps,

+ 6 - 5
apps/app/src/pages/_app.page.tsx

@@ -13,11 +13,12 @@ import * as nextI18nConfig from '^/config/next-i18next.config';
 
 import { GlobalFonts } from '~/components/FontFamily/GlobalFonts';
 import type { CrowiRequest } from '~/interfaces/crowi-request';
-import { useAutoUpdateGlobalAtoms } from '~/states/auto-update/global';
-import { useHydrateGlobalAtoms } from '~/states/hydrate/global';
+import { useAutoUpdateGlobalAtoms } from '~/states/global/auto-update';
+import { useHydrateGlobalInitialAtoms } from '~/states/global/hydrate';
 import { swrGlobalConfiguration } from '~/utils/swr-utils';
 
-import { getLocaleAtServerSide, type CommonProps } from './utils/commons';
+import type { CommonEachProps, CommonInitialProps } from './utils/commons';
+import { getLocaleAtServerSide } from './utils/locale';
 import { useNextjsRoutingPageRegister } from './utils/nextjs-routing-utils';
 import { registerTransformerForObjectId } from './utils/objectid-transformer';
 
@@ -40,10 +41,10 @@ registerTransformerForObjectId();
 function GrowiApp({ Component, pageProps, userLocale }: GrowiAppProps): JSX.Element {
   const router = useRouter();
 
-  const commonPageProps = pageProps as CommonProps;
+  const commonPageProps = pageProps as CommonInitialProps & CommonEachProps;
 
   // Hydrate global atoms with server-side data
-  useHydrateGlobalAtoms(commonPageProps);
+  useHydrateGlobalInitialAtoms(commonPageProps);
   useAutoUpdateGlobalAtoms(commonPageProps);
 
   useNextjsRoutingPageRegister(commonPageProps.nextjsRoutingPage);

+ 2 - 1
apps/app/src/pages/_document.page.tsx

@@ -11,7 +11,8 @@ import type { GrowiPluginResourceEntries } from '~/features/growi-plugin/server/
 import type { CrowiRequest } from '~/interfaces/crowi-request';
 import loggerFactory from '~/utils/logger';
 
-import { getLocaleAtServerSide } from './utils/commons';
+import { getLocaleAtServerSide } from './utils/locale';
+
 
 const logger = loggerFactory('growi:page:_document');
 

+ 0 - 2
apps/app/src/states/global/index.ts

@@ -1,3 +1 @@
-export * from './auto-update';
 export * from './global';
-export * from './hydrate';

+ 2 - 2
apps/app/src/states/hydrate/sidebar.ts

@@ -16,10 +16,10 @@ import {
  * @param sidebarConfig - Server-side sidebar configuration
  * @param userUISettings - User's UI settings from database (optional)
  */
-export const useHydrateSidebarAtoms = (sidebarConfig: ISidebarConfig, userUISettings?: IUserUISettings): void => {
+export const useHydrateSidebarAtoms = (sidebarConfig?: ISidebarConfig, userUISettings?: IUserUISettings): void => {
   useHydrateAtoms([
     // Use user preference from DB if available, otherwise use system default
-    [preferCollapsedModeAtom, userUISettings?.preferCollapsedModeByUser ?? sidebarConfig.isSidebarCollapsedMode],
+    [preferCollapsedModeAtom, userUISettings?.preferCollapsedModeByUser ?? sidebarConfig?.isSidebarCollapsedMode ?? false],
 
     // Sidebar contents type (with default fallback)
     [currentSidebarContentsAtom, userUISettings?.currentSidebarContents ?? SidebarContentsType.TREE],