From 7de17e50cac9170dd270add6c161a8af04632fb2 Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 28 Feb 2025 14:40:56 +0100 Subject: [PATCH] rename to `setUnrecoverableError` and remove onLeave call because that will be handled by an effect. --- src/room/GroupCallView.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index 88764b59..04e1080e 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -69,7 +69,7 @@ import { ElementCallError, ErrorCategory, ErrorCode, - RTCSessionError + RTCSessionError, } from "../utils/errors.ts"; import { ElementCallRichError } from "../RichError.tsx"; import { @@ -139,13 +139,12 @@ export const GroupCallView: FC = ({ rtcSession, MatrixRTCSessionEvent.MembershipManagerError, (error) => { - setEnterRTCError( + setUnrecoverableError( new RTCSessionError( ErrorCode.MEMBERSHIP_MANAGER_UNRECOVERABLE, error.message ?? error, ), ); - onLeave("error"); }, ); useEffect(() => { @@ -214,7 +213,7 @@ export const GroupCallView: FC = ({ } catch (e) { if (e instanceof ElementCallError) { // e.code === ErrorCode.MISSING_LIVE_KIT_SERVICE_URL) - setEnterRTCError(e); + setUnrecoverableError(e); } else { logger.error(`Unknown Error while entering RTC session`, e); const error = new ElementCallError( @@ -222,7 +221,7 @@ export const GroupCallView: FC = ({ ErrorCode.UNKNOWN_ERROR, ErrorCategory.UNKNOWN, ); - setEnterRTCError(error); + setUnrecoverableError(error); } } }; @@ -322,9 +321,8 @@ export const GroupCallView: FC = ({ ]); const [left, setLeft] = useState(false); - const [enterRTCError, setEnterRTCError] = useState( - null, - ); + const [unrecoverableError, setUnrecoverableError] = + useState(null); const navigate = useNavigate(); const onLeave = useCallback( @@ -495,11 +493,11 @@ export const GroupCallView: FC = ({ ); let body: ReactNode; - if (enterRTCError) { + if (unrecoverableError) { // If an ElementCallError was recorded, then create a component that will fail to render and throw // an ElementCallRichError error. This will then be handled by the ErrorBoundary component. const ErrorComponent = (): ReactNode => { - throw new ElementCallRichError(enterRTCError); + throw new ElementCallRichError(unrecoverableError); }; body = ; } else if (isJoined) {