Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

🩹(frontend) clear router state on page reload

lebaudantoinec21c5f604b24
diff --git a/src/frontend/src/features/rooms/routes/Room.tsx b/src/frontend/src/features/rooms/routes/Room.tsx
index eb4a531a..629ba2c1 100644
--- a/src/frontend/src/features/rooms/routes/Room.tsx
+++ b/src/frontend/src/features/rooms/routes/Room.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useEffect, useState } from 'react'
import {
usePersistentUserChoices,
type LocalUserChoices,
@@ -19,6 +19,19 @@ export const Room = () => {
const mode = isLoggedIn && history.state?.create ? 'create' : 'join'
const skipJoinScreen = isLoggedIn && mode === 'create'
+ const clearRouterState = () => {
+ if (window?.history?.state) {
+ window.history.replaceState({}, '')
+ }
+ }
+
+ useEffect(() => {
+ window.addEventListener('beforeunload', clearRouterState)
+ return () => {
+ window.removeEventListener('beforeunload', clearRouterState)
+ }
+ }, [])
+
if (!roomId) {
return <ErrorScreen />
}