fix: should render entry content when refresh page

- Added a new effect to manage the rendering of the details column based on the timeline's state.
- Updated dependencies in the width adjustment effect to ensure proper layout updates.
- Cleaned up unnecessary state updates to enhance performance.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2025-10-27 23:16:59 +08:00
parent 68b8a65429
commit 65249b45c7
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
1 changed files with 8 additions and 4 deletions

View File

@ -69,6 +69,7 @@ const AIEnhancedTimelineLayoutImpl = () => {
const layoutContainerRef = useRef<HTMLDivElement>(null)
const hasMountedRef = useRef(false)
// Delay the details column until the timeline width animation finishes
const [shouldRenderDetailsColumn, setShouldRenderDetailsColumn] = useState(showEntryDetailsColumn)
const feedColumnWidth = useUISettingKey("feedColWidth")
@ -158,7 +159,7 @@ const AIEnhancedTimelineLayoutImpl = () => {
setAiPanelWidth(width)
// Trigger layout update
window.dispatchEvent(new Event("resize"))
}, [resolvePreferredWidth])
}, [resolvePreferredWidth, setAiPanelWidth])
const handleTimelineTransitionEnd = useCallback(
(event: TransitionEvent<HTMLDivElement>) => {
@ -174,15 +175,18 @@ const AIEnhancedTimelineLayoutImpl = () => {
[showEntryDetailsColumn],
)
useEffect(() => {
if (!showEntryDetailsColumn) {
setShouldRenderDetailsColumn(false)
}
}, [showEntryDetailsColumn])
useEffect(() => {
if (!hasMountedRef.current) {
hasMountedRef.current = true
setShouldRenderDetailsColumn(showEntryDetailsColumn)
return
}
// Defer rendering until the width transition signals completion
setShouldRenderDetailsColumn(false)
}, [showEntryDetailsColumn])
return (