mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
Fix lint errors
Various hooks either missing dependencies or with extra ones. Two remaining errors are from the recapcta code where I can't work out if the extra dependency is intentional or not.
This commit is contained in:
parent
dbef06269b
commit
bf8f164f55
@ -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",
|
||||
|
@ -7,39 +7,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];
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export function useInteractiveRegistration() {
|
||||
|
||||
return client;
|
||||
},
|
||||
[]
|
||||
[setClient]
|
||||
);
|
||||
|
||||
return [state, register];
|
||||
|
@ -81,7 +81,7 @@ export function useGroupCallRooms(client) {
|
||||
client.removeListener("GroupCall.incoming", updateRooms);
|
||||
client.removeListener("GroupCall.participants", updateRooms);
|
||||
};
|
||||
}, []);
|
||||
}, [client]);
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
@ -86,7 +86,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;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||
|
||||
setState((prevState) => ({ ...prevState, pttButtonHeld: true }));
|
||||
}
|
||||
}, []);
|
||||
}, [groupCall, activeSpeakerUserId, isAdmin, talkOverEnabled]);
|
||||
|
||||
const stopTalking = useCallback(() => {
|
||||
if (!groupCall.isMicrophoneMuted()) {
|
||||
@ -63,7 +63,7 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||
}
|
||||
|
||||
setState((prevState) => ({ ...prevState, pttButtonHeld: false }));
|
||||
}, []);
|
||||
}, [groupCall]);
|
||||
|
||||
useEffect(() => {
|
||||
function onKeyDown(event) {
|
||||
@ -100,7 +100,14 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||
window.removeEventListener("keyup", onKeyUp);
|
||||
window.removeEventListener("blur", onBlur);
|
||||
};
|
||||
}, [activeSpeakerUserId, isAdmin, talkOverEnabled]);
|
||||
}, [
|
||||
groupCall,
|
||||
startTalking,
|
||||
stopTalking,
|
||||
activeSpeakerUserId,
|
||||
isAdmin,
|
||||
talkOverEnabled,
|
||||
]);
|
||||
|
||||
const setTalkOverEnabled = useCallback((talkOverEnabled) => {
|
||||
setState((prevState) => ({
|
||||
|
@ -223,7 +223,7 @@ export function useSubmitRageshake() {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
[client]
|
||||
[client, json, sending]
|
||||
);
|
||||
|
||||
return {
|
||||
@ -294,7 +294,7 @@ export function useRageshakeRequestModal(roomId) {
|
||||
return () => {
|
||||
client.removeListener("event", onEvent);
|
||||
};
|
||||
}, [modalState.open, roomId]);
|
||||
}, [modalState.open, roomId, client, modalState]);
|
||||
|
||||
return { modalState, modalProps: { ...modalProps, rageshakeRequestId } };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user