From 18ba02c9c26d78d9fb0cd9c67834bccccb78e089 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 7 Oct 2025 16:29:11 +0200 Subject: [PATCH] knip: remove dead code --- src/room/MuteStates.ts | 11 ++++---- src/useMatrixRTCSessionJoinState.ts | 40 ----------------------------- src/utils/test-fixtures.ts | 3 +-- 3 files changed, 7 insertions(+), 47 deletions(-) delete mode 100644 src/useMatrixRTCSessionJoinState.ts diff --git a/src/room/MuteStates.ts b/src/room/MuteStates.ts index e89d13d9..dfc599e7 100644 --- a/src/room/MuteStates.ts +++ b/src/room/MuteStates.ts @@ -27,11 +27,12 @@ import { ElementWidgetActions, widget } from "../widget"; import { Config } from "../config/Config"; import { useUrlParams } from "../UrlParams"; -/** - * If there already are this many participants in the call, we automatically mute - * the user. - */ -export const MUTE_PARTICIPANT_COUNT = 8; +// /** +// * If there already are this many participants in the call, we automatically mute +// * the user. +// */ +// TODO: multi-sfu dead code? +// export const MUTE_PARTICIPANT_COUNT = 8; interface DeviceAvailable { enabled: boolean; diff --git a/src/useMatrixRTCSessionJoinState.ts b/src/useMatrixRTCSessionJoinState.ts deleted file mode 100644 index 2f6ccf25..00000000 --- a/src/useMatrixRTCSessionJoinState.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2023, 2024 New Vector Ltd. - -SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial -Please see LICENSE in the repository root for full details. -*/ - -import { logger } from "matrix-js-sdk/lib/logger"; -import { - type MatrixRTCSession, - MatrixRTCSessionEvent, -} from "matrix-js-sdk/lib/matrixrtc"; -import { TypedEventEmitter } from "matrix-js-sdk"; -import { useCallback, useEffect } from "react"; - -import { useTypedEventEmitterState } from "./useEvents"; - -const dummySession = new TypedEventEmitter(); - -export function useMatrixRTCSessionJoinState( - rtcSession: MatrixRTCSession | undefined, -): boolean { - // React doesn't allow you to run a hook conditionally, so we have to plug in - // a dummy event emitter in case there is no rtcSession yet - const isJoined = useTypedEventEmitterState( - rtcSession ?? dummySession, - MatrixRTCSessionEvent.JoinStateChanged, - useCallback(() => rtcSession?.isJoined() ?? false, [rtcSession]), - ); - - useEffect(() => { - logger.info( - `Session in room ${rtcSession?.room.roomId} changed to ${ - isJoined ? "joined" : "left" - }`, - ); - }, [rtcSession, isJoined]); - - return isJoined; -} diff --git a/src/utils/test-fixtures.ts b/src/utils/test-fixtures.ts index 6a8b641b..9d93267e 100644 --- a/src/utils/test-fixtures.ts +++ b/src/utils/test-fixtures.ts @@ -9,7 +9,6 @@ import { mockRtcMembership, mockMatrixRoomMember, mockRemoteParticipant, - mockLocalParticipant, } from "./test"; export const localRtcMember = mockRtcMembership("@carol:example.org", "1111"); @@ -18,7 +17,7 @@ export const localRtcMemberDevice2 = mockRtcMembership( "2222", ); export const local = mockMatrixRoomMember(localRtcMember); -export const localParticipant = mockLocalParticipant({ identity: "" }); +// export const localParticipant = mockLocalParticipant({ identity: "" }); export const localId = `${local.userId}:${localRtcMember.deviceId}`; export const aliceRtcMember = mockRtcMembership("@alice:example.org", "AAAA");