File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
components/PageView/PageAlerts Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,8 @@ import type { JSX } from 'react';
33import dynamic from 'next/dynamic' ;
44
55import { useHashChangedEffect } from '~/client/services/side-effects/hash-changed' ;
6- import { useIsEditable } from '~/states/page' ;
6+ import { useIsEditable , useRevisionIdFromUrl } from '~/states/page' ;
77import { EditorMode , useEditorMode , useReservedNextCaretLine } from '~/states/ui/editor' ;
8- import { useSWRxIsLatestRevision } from '~/stores/page' ;
98
109import { LazyRenderer } from '../Common/LazyRenderer' ;
1110
@@ -18,14 +17,15 @@ export const DisplaySwitcher = (): JSX.Element => {
1817
1918 const { editorMode } = useEditorMode ( ) ;
2019 const isEditable = useIsEditable ( ) ;
21- const { data : isLatestRevision } = useSWRxIsLatestRevision ( ) ;
20+ const revisionIdFromUrl = useRevisionIdFromUrl ( ) ;
2221
2322 useHashChangedEffect ( ) ;
2423 useReservedNextCaretLine ( ) ;
2524
2625 return (
2726 < LazyRenderer shouldRender = { isEditable === true && editorMode === EditorMode . Editor } >
28- { isLatestRevision !== false
27+ { /* Display <PageEditorReadOnly /> when the user is intentionally viewing a specific (past) revision. */ }
28+ { revisionIdFromUrl == null
2929 ? < PageEditor />
3030 : < PageEditorReadOnly />
3131 }
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export const usePageUpdatedEffect = (): void => {
4545
4646 // !!CAUTION!! Timing of calling openPageStatusAlert may clash with components/PageEditor/conflict.tsx
4747 if ( isRevisionOutdated && editorMode === EditorMode . View ) {
48- openPageStatusAlert ( { hideEditorMode : EditorMode . Editor , onRefleshPage : fetchCurrentPage } ) ;
48+ openPageStatusAlert ( { hideEditorMode : EditorMode . Editor , onRefleshPage : ( ) => fetchCurrentPage ( { force : true } ) } ) ;
4949 }
5050
5151 // Clear cache
Original file line number Diff line number Diff line change @@ -3,14 +3,17 @@ import { useRouter } from 'next/router';
33import { returnPathForURL } from '@growi/core/dist/utils/path-utils' ;
44import { useTranslation } from 'react-i18next' ;
55
6- import { useCurrentPageData , useFetchCurrentPage } from '~/states/page' ;
7- import { useSWRxIsLatestRevision } from '~/stores/page' ;
6+ import {
7+ useCurrentPageData ,
8+ useFetchCurrentPage ,
9+ useRevisionIdFromUrl ,
10+ } from '~/states/page' ;
811
912export const OldRevisionAlert = ( ) : JSX . Element => {
1013 const router = useRouter ( ) ;
1114 const { t } = useTranslation ( ) ;
1215
13- const { data : isLatestRevision } = useSWRxIsLatestRevision ( ) ;
16+ const revisionIdFromUrl = useRevisionIdFromUrl ( ) ;
1417 const page = useCurrentPageData ( ) ;
1518 const { fetchCurrentPage } = useFetchCurrentPage ( ) ;
1619
@@ -24,8 +27,8 @@ export const OldRevisionAlert = (): JSX.Element => {
2427 fetchCurrentPage ( { force : true } ) ;
2528 } , [ fetchCurrentPage , page , router ] ) ;
2629
27- // Show alert only when viewing an old revision (isLatestRevision === false )
28- if ( isLatestRevision ! == false ) {
30+ // Show alert only when intentionally viewing a specific (past) revision (revisionIdFromUrl != null )
31+ if ( revisionIdFromUrl == null ) {
2932 // biome-ignore lint/complexity/noUselessFragments: ignore
3033 return < > </ > ;
3134 }
You can’t perform that action at this time.
0 commit comments