|
@@ -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
|