diff --git a/package.json b/package.json index 1cd926f..3ac338e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build-storybook": "build-storybook", "prettier:check": "prettier -c src", "prettier:format": "prettier -w src", - "lint": "eslint --max-warnings 11 src" + "lint": "eslint --max-warnings 2 src" }, "dependencies": { "@juggle/resize-observer": "^3.3.1", diff --git a/src/auth/useInteractiveLogin.js b/src/auth/useInteractiveLogin.js index fd31d07..6cdd4bd 100644 --- a/src/auth/useInteractiveLogin.js +++ b/src/auth/useInteractiveLogin.js @@ -23,39 +23,42 @@ export function useInteractiveLogin() { const { setClient } = useClient(); const [state, setState] = useState({ loading: false }); - const auth = useCallback(async (homeserver, username, password) => { - const authClient = matrix.createClient(homeserver); + const auth = useCallback( + async (homeserver, username, password) => { + const authClient = matrix.createClient(homeserver); - const interactiveAuth = new InteractiveAuth({ - matrixClient: authClient, - busyChanged(loading) { - setState((prev) => ({ ...prev, loading })); - }, - async doRequest(_auth, _background) { - return authClient.login("m.login.password", { - identifier: { - type: "m.id.user", - user: username, - }, - password, - }); - }, - }); + const interactiveAuth = new InteractiveAuth({ + matrixClient: authClient, + busyChanged(loading) { + setState((prev) => ({ ...prev, loading })); + }, + async doRequest(_auth, _background) { + return authClient.login("m.login.password", { + identifier: { + type: "m.id.user", + user: username, + }, + password, + }); + }, + }); - const { user_id, access_token, device_id } = - await interactiveAuth.attemptAuth(); + const { user_id, access_token, device_id } = + await interactiveAuth.attemptAuth(); - const client = await initClient({ - baseUrl: defaultHomeserver, - accessToken: access_token, - userId: user_id, - deviceId: device_id, - }); + const client = await initClient({ + baseUrl: defaultHomeserver, + accessToken: access_token, + userId: user_id, + deviceId: device_id, + }); - setClient(client, { user_id, access_token, device_id }); + setClient(client, { user_id, access_token, device_id }); - return client; - }, []); + return client; + }, + [setClient] + ); return [state, auth]; } diff --git a/src/auth/useInteractiveRegistration.js b/src/auth/useInteractiveRegistration.js index 55da7d0..583df1c 100644 --- a/src/auth/useInteractiveRegistration.js +++ b/src/auth/useInteractiveRegistration.js @@ -105,7 +105,7 @@ export function useInteractiveRegistration() { return client; }, - [] + [setClient] ); return [state, register]; diff --git a/src/home/useGroupCallRooms.js b/src/home/useGroupCallRooms.js index aa4246d..8cd0958 100644 --- a/src/home/useGroupCallRooms.js +++ b/src/home/useGroupCallRooms.js @@ -97,7 +97,7 @@ export function useGroupCallRooms(client) { client.removeListener("GroupCall.incoming", updateRooms); client.removeListener("GroupCall.participants", updateRooms); }; - }, []); + }, [client]); return rooms; } diff --git a/src/room/useLoadGroupCall.js b/src/room/useLoadGroupCall.js index 19420b6..894fded 100644 --- a/src/room/useLoadGroupCall.js +++ b/src/room/useLoadGroupCall.js @@ -102,7 +102,7 @@ export function useLoadGroupCall(client, roomId, viaServers, createIfNotFound) { .catch((error) => setState((prevState) => ({ ...prevState, loading: false, error })) ); - }, [client, roomId, state.reloadId]); + }, [client, roomId, state.reloadId, createIfNotFound, viaServers]); return state; } diff --git a/src/room/usePTT.js b/src/room/usePTT.js index c3c2f76..06ab17e 100644 --- a/src/room/usePTT.js +++ b/src/room/usePTT.js @@ -85,7 +85,7 @@ export function usePTT(client, groupCall, userMediaFeeds) { } } } - }, [setState]); + }, [groupCall, activeSpeakerUserId, isAdmin, talkOverEnabled, setState]); const stopTalking = useCallback(() => { setState((prevState) => ({ ...prevState, pttButtonHeld: false })); @@ -93,7 +93,9 @@ export function usePTT(client, groupCall, userMediaFeeds) { if (!groupCall.isMicrophoneMuted()) { groupCall.setMicrophoneMuted(true); } - }, []); + + setState((prevState) => ({ ...prevState, pttButtonHeld: false })); + }, [groupCall]); useEffect(() => { function onKeyDown(event) { @@ -132,7 +134,15 @@ export function usePTT(client, groupCall, userMediaFeeds) { window.removeEventListener("keyup", onKeyUp); window.removeEventListener("blur", onBlur); }; - }, [activeSpeakerUserId, isAdmin, talkOverEnabled, pttButtonHeld]); + }, [ + groupCall, + startTalking, + stopTalking, + activeSpeakerUserId, + isAdmin, + talkOverEnabled, + pttButtonHeld, + ]); const setTalkOverEnabled = useCallback((talkOverEnabled) => { setState((prevState) => ({ diff --git a/src/settings/submit-rageshake.js b/src/settings/submit-rageshake.js index 23978d8..3c10e57 100644 --- a/src/settings/submit-rageshake.js +++ b/src/settings/submit-rageshake.js @@ -239,7 +239,7 @@ export function useSubmitRageshake() { console.error(error); } }, - [client] + [client, json, sending] ); return { @@ -310,7 +310,7 @@ export function useRageshakeRequestModal(roomId) { return () => { client.removeListener("event", onEvent); }; - }, [modalState.open, roomId]); + }, [modalState.open, roomId, client, modalState]); return { modalState, modalProps: { ...modalProps, rageshakeRequestId } }; }