mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-02-06 18:56:48 +00:00
refactor: remove redundant fatalError ref, use state directly in handleLeave
This commit is contained in:
@@ -254,7 +254,6 @@ export default function DailyRoom({ meeting, room }: DailyRoomProps) {
|
|||||||
const startRecordingMutation = useMeetingStartRecording();
|
const startRecordingMutation = useMeetingStartRecording();
|
||||||
const [joinedMeeting, setJoinedMeeting] = useState<Meeting | null>(null);
|
const [joinedMeeting, setJoinedMeeting] = useState<Meeting | null>(null);
|
||||||
const [fatalError, setFatalError] = useState<FatalError | null>(null);
|
const [fatalError, setFatalError] = useState<FatalError | null>(null);
|
||||||
const fatalErrorRef = useRef<FatalError | null>(null);
|
|
||||||
|
|
||||||
// Generate deterministic instanceIds so all participants use SAME IDs
|
// Generate deterministic instanceIds so all participants use SAME IDs
|
||||||
const cloudInstanceId = parseNonEmptyString(meeting.id);
|
const cloudInstanceId = parseNonEmptyString(meeting.id);
|
||||||
@@ -302,16 +301,15 @@ export default function DailyRoom({ meeting, room }: DailyRoomProps) {
|
|||||||
|
|
||||||
const handleLeave = useCallback(() => {
|
const handleLeave = useCallback(() => {
|
||||||
// If a fatal error occurred, don't redirect — let the error UI show
|
// If a fatal error occurred, don't redirect — let the error UI show
|
||||||
if (fatalErrorRef.current) return;
|
if (fatalError) return;
|
||||||
router.push("/browse");
|
router.push("/browse");
|
||||||
}, [router]);
|
}, [router, fatalError]);
|
||||||
|
|
||||||
const handleError = useCallback((ev: DailyEventObjectFatalError) => {
|
const handleError = useCallback((ev: DailyEventObjectFatalError) => {
|
||||||
const error: FatalError = {
|
const error: FatalError = {
|
||||||
type: ev.error?.type ?? "unknown",
|
type: ev.error?.type ?? "unknown",
|
||||||
message: ev.errorMsg,
|
message: ev.errorMsg,
|
||||||
};
|
};
|
||||||
fatalErrorRef.current = error;
|
|
||||||
setFatalError(error);
|
setFatalError(error);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user