Skip to content

Commit

Permalink
Auto-redirect to legacy.replay.io (#10427)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn authored Mar 12, 2024
1 parent 487b8ba commit f18d19d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ui/components/DevTools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function _DevTools({
};

if (unsupportedTarget) {
return <UnsupportedTarget target={unsupportedTarget} />;
return <UnsupportedTarget />;
}

if (!loadingFinished) {
Expand Down
33 changes: 24 additions & 9 deletions src/ui/components/UnsupportedTarget.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
export function UnsupportedTarget({ target }: { target: string }) {
import { useEffect, useState } from "react";

export function UnsupportedTarget() {
const url = new URL(window.location.href);
url.pathname + url.search;
const redirectUrl = `https://legacy.replay.io${url.pathname + url.search}`;

const [count, setCount] = useState(5);

useEffect(() => {
if (count <= 0) {
window.location.href = redirectUrl;
} else {
const timeout = setTimeout(() => {
setCount(count - 1);
}, 1000);

return () => {
clearTimeout(timeout);
};
}
}, [count, redirectUrl]);

return (
<div className="flex h-full items-center justify-center space-y-4">
<div>
Recordings made with <strong>{target}</strong> must be viewed at{" "}
<a
className="pointer-hand underline"
href={`https://legacy.replay.io${url.pathname + url.search}`}
>
Redirecting to{" "}
<a className="pointer-hand underline" href={redirectUrl}>
legacy.replay.io
</a>
.
</a>{" "}
in {count}...
</div>
</div>
);
Expand Down

0 comments on commit f18d19d

Please sign in to comment.