Skip to content

Commit

Permalink
feat: back to dashboard when it's disconnected for too long
Browse files Browse the repository at this point in the history
  • Loading branch information
messi-yang committed Mar 29, 2024
1 parent a815e16 commit d486f4a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pages/worlds/[id].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,18 @@ const Page: NextPage = function Page() {
});
}, [worldJourneyService]);

const isReconnectModalVisible = connectionStatus === 'DISCONNECTED';
const isDisconnected = connectionStatus === 'DISCONNECTED';
useEffect(() => {
if (!isDisconnected) return () => {};

const timeout = setTimeout(() => {
window.location.href = '/dashboard/worlds';
}, 5000);

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

useEffect(
function enterWorldOnInit() {
Expand Down Expand Up @@ -207,7 +218,7 @@ const Page: NextPage = function Page() {
<main className="relative w-full h-screen">
{embedCode && <EmbedModal opened embedCode={embedCode} onClose={cleanEmbedCode} />}
<MessageModal
opened={isReconnectModalVisible}
opened={isDisconnected}
message="You're disconnected to the world."
buttonCopy="Reconnect"
onComfirm={handleRecconectModalConfirmClick}
Expand Down

0 comments on commit d486f4a

Please sign in to comment.