Yuki Takei 7 luni în urmă
părinte
comite
2cc5f4b1b3

BIN
.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl


+ 9 - 0
apps/app/src/pages/[[...path]]/navigation-utils.ts

@@ -1,6 +1,8 @@
 import { isPermalink } from '@growi/core/dist/utils/page-path-utils';
 import { isPermalink } from '@growi/core/dist/utils/page-path-utils';
 import { removeHeadingSlash } from '@growi/core/dist/utils/path-utils';
 import { removeHeadingSlash } from '@growi/core/dist/utils/path-utils';
 
 
+import type { Props, InitialProps, SameRouteEachProps } from './types';
+
 /**
 /**
  * Extract pageId from pathname efficiently
  * Extract pageId from pathname efficiently
  * Returns null for non-permalink paths to optimize conditional checks
  * Returns null for non-permalink paths to optimize conditional checks
@@ -8,3 +10,10 @@ import { removeHeadingSlash } from '@growi/core/dist/utils/path-utils';
 export const extractPageIdFromPathname = (pathname: string): string | null => {
 export const extractPageIdFromPathname = (pathname: string): string | null => {
   return isPermalink(pathname) ? removeHeadingSlash(pathname) : null;
   return isPermalink(pathname) ? removeHeadingSlash(pathname) : null;
 };
 };
+/**
+ * Type guard to check if props are initial props
+ * Returns true if props contain initial data from SSR
+ */
+export const isInitialProps = (props: Props): props is (InitialProps & SameRouteEachProps) => {
+  return 'isNextjsRoutingTypeInitial' in props && props.isNextjsRoutingTypeInitial;
+};

+ 3 - 8
apps/app/src/pages/[[...path]]/use-same-route-navigation.ts

@@ -1,4 +1,4 @@
-import { useEffect, useMemo, useRef } from 'react';
+import { useEffect, useRef } from 'react';
 
 
 import { useRouter } from 'next/router';
 import { useRouter } from 'next/router';
 
 
@@ -7,8 +7,8 @@ import {
 } from '../../states/page';
 } from '../../states/page';
 import { useEditingMarkdown } from '../../stores/editor';
 import { useEditingMarkdown } from '../../stores/editor';
 
 
-import { extractPageIdFromPathname } from './navigation-utils';
-import type { Props, InitialProps, SameRouteEachProps } from './types';
+import { extractPageIdFromPathname, isInitialProps } from './navigation-utils';
+import type { Props } from './types';
 
 
 /**
 /**
  * Custom hook for handling same-route navigation and fetching page data when needed
  * Custom hook for handling same-route navigation and fetching page data when needed
@@ -27,11 +27,6 @@ export const useSameRouteNavigation = (
   const lastProcessedPathnameRef = useRef<string | null>(null);
   const lastProcessedPathnameRef = useRef<string | null>(null);
   const isFetchingRef = useRef<boolean>(false);
   const isFetchingRef = useRef<boolean>(false);
 
 
-  // Type guard to check if props are initial props
-  const isInitialProps = (props: Props): props is (InitialProps & SameRouteEachProps) => {
-    return 'isNextjsRoutingTypeInitial' in props && props.isNextjsRoutingTypeInitial;
-  };
-
   // Process pathname changes - monitor both props.currentPathname and router.asPath
   // Process pathname changes - monitor both props.currentPathname and router.asPath
   useEffect(() => {
   useEffect(() => {
     // Use router.asPath for browser back/forward compatibility, fallback to props.currentPathname
     // Use router.asPath for browser back/forward compatibility, fallback to props.currentPathname