Fix back navigation when coming from direct shared timestamp links

This commit is contained in:
0x464e 2026-04-05 15:05:21 +03:00
parent 0fb507ae3c
commit 8d462588fc
No known key found for this signature in database
GPG Key ID: E6D221DF6CBFBFFA
3 changed files with 13 additions and 1 deletions

View File

@ -280,6 +280,7 @@ export default function Events() {
// this pattern is also used LiveCameraView to enter recording view // this pattern is also used LiveCameraView to enter recording view
severity: "alert", severity: "alert",
timelineType: notificationTab, timelineType: notificationTab,
navigationSource: "shared-link",
}, },
true, true,
); );

View File

@ -40,6 +40,7 @@ export type RecordingStartingPoint = {
startTime: number; startTime: number;
severity: ReviewSeverity; severity: ReviewSeverity;
timelineType?: TimelineType; timelineType?: TimelineType;
navigationSource?: "shared-link";
}; };
export type RecordingPlayerError = "stalled" | "startup"; export type RecordingPlayerError = "stalled" | "startup";

View File

@ -349,6 +349,16 @@ export function RecordingView({
[location.pathname, mainCamera, t], [location.pathname, mainCamera, t],
); );
const handleBack = useCallback(() => {
// if we came from a direct share link, there is no history to go back to, so navigate to the homepage instead
if (recording?.navigationSource === "shared-link") {
navigate("/");
return;
}
navigate(-1);
}, [navigate, recording?.navigationSource]);
useEffect(() => { useEffect(() => {
if (!scrubbing) { if (!scrubbing) {
if (Math.abs(currentTime - playerTime) > 10) { if (Math.abs(currentTime - playerTime) > 10) {
@ -599,7 +609,7 @@ export function RecordingView({
className="flex items-center gap-2.5 rounded-lg" className="flex items-center gap-2.5 rounded-lg"
aria-label={t("label.back", { ns: "common" })} aria-label={t("label.back", { ns: "common" })}
size="sm" size="sm"
onClick={() => navigate(-1)} onClick={handleBack}
> >
<IoMdArrowRoundBack className="size-5 text-secondary-foreground" /> <IoMdArrowRoundBack className="size-5 text-secondary-foreground" />
{isDesktop && ( {isDesktop && (