Merge pull request #315 from vector-im/dbkr/fix_lint_errors

Fix lint errors
This commit is contained in:
David Baker 2022-05-06 21:35:55 +01:00 committed by GitHub
commit 7a561bd034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 37 deletions

View file

@ -8,7 +8,7 @@
"build-storybook": "build-storybook", "build-storybook": "build-storybook",
"prettier:check": "prettier -c src", "prettier:check": "prettier -c src",
"prettier:format": "prettier -w src", "prettier:format": "prettier -w src",
"lint": "eslint --max-warnings 11 src" "lint": "eslint --max-warnings 2 src"
}, },
"dependencies": { "dependencies": {
"@juggle/resize-observer": "^3.3.1", "@juggle/resize-observer": "^3.3.1",

View file

@ -23,39 +23,42 @@ export function useInteractiveLogin() {
const { setClient } = useClient(); const { setClient } = useClient();
const [state, setState] = useState({ loading: false }); const [state, setState] = useState({ loading: false });
const auth = useCallback(async (homeserver, username, password) => { const auth = useCallback(
const authClient = matrix.createClient(homeserver); async (homeserver, username, password) => {
const authClient = matrix.createClient(homeserver);
const interactiveAuth = new InteractiveAuth({ const interactiveAuth = new InteractiveAuth({
matrixClient: authClient, matrixClient: authClient,
busyChanged(loading) { busyChanged(loading) {
setState((prev) => ({ ...prev, loading })); setState((prev) => ({ ...prev, loading }));
}, },
async doRequest(_auth, _background) { async doRequest(_auth, _background) {
return authClient.login("m.login.password", { return authClient.login("m.login.password", {
identifier: { identifier: {
type: "m.id.user", type: "m.id.user",
user: username, user: username,
}, },
password, password,
}); });
}, },
}); });
const { user_id, access_token, device_id } = const { user_id, access_token, device_id } =
await interactiveAuth.attemptAuth(); await interactiveAuth.attemptAuth();
const client = await initClient({ const client = await initClient({
baseUrl: defaultHomeserver, baseUrl: defaultHomeserver,
accessToken: access_token, accessToken: access_token,
userId: user_id, userId: user_id,
deviceId: device_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]; return [state, auth];
} }

View file

@ -105,7 +105,7 @@ export function useInteractiveRegistration() {
return client; return client;
}, },
[] [setClient]
); );
return [state, register]; return [state, register];

View file

@ -97,7 +97,7 @@ export function useGroupCallRooms(client) {
client.removeListener("GroupCall.incoming", updateRooms); client.removeListener("GroupCall.incoming", updateRooms);
client.removeListener("GroupCall.participants", updateRooms); client.removeListener("GroupCall.participants", updateRooms);
}; };
}, []); }, [client]);
return rooms; return rooms;
} }

View file

@ -102,7 +102,7 @@ export function useLoadGroupCall(client, roomId, viaServers, createIfNotFound) {
.catch((error) => .catch((error) =>
setState((prevState) => ({ ...prevState, loading: false, error })) setState((prevState) => ({ ...prevState, loading: false, error }))
); );
}, [client, roomId, state.reloadId]); }, [client, roomId, state.reloadId, createIfNotFound, viaServers]);
return state; return state;
} }

View file

@ -85,7 +85,7 @@ export function usePTT(client, groupCall, userMediaFeeds) {
} }
} }
} }
}, [setState]); }, [groupCall, activeSpeakerUserId, isAdmin, talkOverEnabled, setState]);
const stopTalking = useCallback(() => { const stopTalking = useCallback(() => {
setState((prevState) => ({ ...prevState, pttButtonHeld: false })); setState((prevState) => ({ ...prevState, pttButtonHeld: false }));
@ -93,7 +93,9 @@ export function usePTT(client, groupCall, userMediaFeeds) {
if (!groupCall.isMicrophoneMuted()) { if (!groupCall.isMicrophoneMuted()) {
groupCall.setMicrophoneMuted(true); groupCall.setMicrophoneMuted(true);
} }
}, []);
setState((prevState) => ({ ...prevState, pttButtonHeld: false }));
}, [groupCall]);
useEffect(() => { useEffect(() => {
function onKeyDown(event) { function onKeyDown(event) {
@ -132,7 +134,15 @@ export function usePTT(client, groupCall, userMediaFeeds) {
window.removeEventListener("keyup", onKeyUp); window.removeEventListener("keyup", onKeyUp);
window.removeEventListener("blur", onBlur); window.removeEventListener("blur", onBlur);
}; };
}, [activeSpeakerUserId, isAdmin, talkOverEnabled, pttButtonHeld]); }, [
groupCall,
startTalking,
stopTalking,
activeSpeakerUserId,
isAdmin,
talkOverEnabled,
pttButtonHeld,
]);
const setTalkOverEnabled = useCallback((talkOverEnabled) => { const setTalkOverEnabled = useCallback((talkOverEnabled) => {
setState((prevState) => ({ setState((prevState) => ({

View file

@ -239,7 +239,7 @@ export function useSubmitRageshake() {
console.error(error); console.error(error);
} }
}, },
[client] [client, json, sending]
); );
return { return {
@ -310,7 +310,7 @@ export function useRageshakeRequestModal(roomId) {
return () => { return () => {
client.removeListener("event", onEvent); client.removeListener("event", onEvent);
}; };
}, [modalState.open, roomId]); }, [modalState.open, roomId, client, modalState]);
return { modalState, modalProps: { ...modalProps, rageshakeRequestId } }; return { modalState, modalProps: { ...modalProps, rageshakeRequestId } };
} }