fix replay bug
Build and Release / release (push) Successful in 35s

This commit is contained in:
taDuc
2026-06-07 18:46:00 +07:00
parent b051b2778f
commit 0ce198aa5e
4 changed files with 66 additions and 21 deletions
@@ -56,8 +56,8 @@ export default function ReplayPreviewOverlay({
style={{
position: "absolute",
inset: 0,
zIndex: 15,
pointerEvents: "none",
zIndex: 60,
pointerEvents: isPreviewMode ? "auto" : "none",
}}
>
{toasts.length ? (
@@ -272,7 +272,7 @@ export default function ReplayPreviewOverlay({
onClick={onResetPreview}
style={previewButtonStyle("#1e3a8a")}
>
Reset
Phát lại từ đu
</button>
</>
) : (
@@ -38,7 +38,7 @@ const guideItems: GuideItem[] = [
{
title: "Nếu đối tượng có replay, nhấn nút phát để xem diễn biến.",
details: [
"Trong quá trình replay có thể dừng và tương tác như bình thường.",
"Trong quá trình replay có thể dừng và tương tác như bình thường(những vì vấn đề kĩ thuật chúng tôi chưa thể làm việc đó mà không xảy ra lỗi, nên hiện tại chức năng replay bị hạn chế tương tác).",
],
},
{
+52 -14
View File
@@ -133,6 +133,13 @@ const PreviewLayout = forwardRef<PreviewLayoutHandle, Props>(({
}, [currentActiveReplay, mode, setPreviewActiveEntityId, setPreviewWikiCache]);
const autoplayedReplayIdRef = useRef<string | number | null>(null);
const playFromStartRef = useRef(replayPreview.playFromStart);
const playFromSelectionRef = useRef(replayPreview.playFromSelection);
useEffect(() => {
playFromStartRef.current = replayPreview.playFromStart;
playFromSelectionRef.current = replayPreview.playFromSelection;
}, [replayPreview.playFromSelection, replayPreview.playFromStart]);
// Autoplay replay on mount/session load
useEffect(() => {
@@ -143,12 +150,16 @@ const PreviewLayout = forwardRef<PreviewLayoutHandle, Props>(({
if (autoplayedReplayIdRef.current === currentActiveReplay.id) return;
autoplayedReplayIdRef.current = currentActiveReplay.id;
if (autoplayMode === "selection") {
replayPreview.playFromSelection();
} else {
replayPreview.playFromStart();
}
}, [autoplayMode, isReplayPreviewMode, currentActiveReplay, replayPreview]);
const timeoutId = window.setTimeout(() => {
if (autoplayMode === "selection") {
playFromSelectionRef.current();
} else {
playFromStartRef.current();
}
}, 30);
return () => window.clearTimeout(timeoutId);
}, [autoplayMode, isReplayPreviewMode, currentActiveReplay]);
const {
timelineYear: replayPreviewTimelineYear,
@@ -644,6 +655,24 @@ const PreviewLayout = forwardRef<PreviewLayoutHandle, Props>(({
};
}, [isReplayPreviewRightPanelOpen, isLargeScreen, previewSidebarWidth]);
const searchBarWrapperStyle = useMemo(() => {
return {
position: "absolute" as const,
top: 10,
left: 84,
right: (isReplayPreviewRightPanelOpen && isLargeScreen) ? previewSidebarWidth + 32 : 18,
zIndex: 18,
display: "flex",
alignItems: "flex-start",
pointerEvents: "none" as const,
maxWidth: "calc(100vw - 102px)",
};
}, [isLargeScreen, isReplayPreviewRightPanelOpen, previewSidebarWidth]);
const searchBarWidth = useMemo(() => {
return "min(392px, calc(100vw - 120px))";
}, []);
// WikiSelectionPanel rows
@@ -673,13 +702,22 @@ const PreviewLayout = forwardRef<PreviewLayoutHandle, Props>(({
return (
<>
<PresentPlaceSearch
focusedPlace={focusedPresentPlace}
onFocusPlace={handleFocusPresentPlace}
onFocusHistoricalGeometry={handleFocusHistoricalGeometry}
onFocusWiki={handleFocusWiki}
onClearFocus={clearPresentPlaceFocus}
/>
<div style={searchBarWrapperStyle}>
<PresentPlaceSearch
focusedPlace={focusedPresentPlace}
onFocusPlace={handleFocusPresentPlace}
onFocusHistoricalGeometry={handleFocusHistoricalGeometry}
onFocusWiki={handleFocusWiki}
onClearFocus={clearPresentPlaceFocus}
style={{
position: "relative",
top: 0,
left: 0,
transform: "none",
width: searchBarWidth,
}}
/>
</div>
{isReplayPreviewMode ? (
<ReplayPreviewOverlay
@@ -695,7 +733,7 @@ const PreviewLayout = forwardRef<PreviewLayoutHandle, Props>(({
totalSteps={replayPreview.totalSteps}
onPlayPreview={replayPreview.playFromStart}
onStopPreview={replayPreview.stopPreview}
onResetPreview={replayPreview.resetPreview}
onResetPreview={replayPreview.playFromStart}
onExitPreview={handleExitReplayPreview}
/>
) : null}
@@ -504,9 +504,16 @@ export default function PublicPreviewClientPage({
}, []);
const handleResetPreviewReplay = useCallback(() => {
setReplayMode("idle");
replayPreview.resetPreview();
}, [replayPreview]);
if (!activeReplay) {
setReplayMode("idle");
replayPreview.resetPreview();
return;
}
setReplayMode("playing");
setSelectedReplayStageId(activeReplay.stageId);
setSelectedReplayStepIndex(activeReplay.stepIndex);
replayPreview.playFromStart();
}, [activeReplay, replayPreview]);
const handleExitReplay = useCallback(() => {
setReplayMode("idle");