TypeScript strict fixes (#10138)

pull/28217/head
Germain 2023-02-10 18:11:57 +00:00 committed by GitHub
parent e57f6f0257
commit f0f50485d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 10 deletions

View File

@ -182,11 +182,11 @@ export default class UserActivity {
this.activeRecentlyTimeout.abort(); this.activeRecentlyTimeout.abort();
}; };
private onUserActivity = (event: MouseEvent): void => { private onUserActivity = (event: Event): void => {
// ignore anything if the window isn't focused // ignore anything if the window isn't focused
if (!this.document.hasFocus()) return; if (!this.document.hasFocus()) return;
if (event.screenX && event.type === "mousemove") { if (event.type === "mousemove" && this.isMouseEvent(event)) {
if (event.screenX === this.lastScreenX && event.screenY === this.lastScreenY) { if (event.screenX === this.lastScreenX && event.screenY === this.lastScreenY) {
// mouse hasn't actually moved // mouse hasn't actually moved
return; return;
@ -223,4 +223,8 @@ export default class UserActivity {
} }
attachedTimers.forEach((t) => t.abort()); attachedTimers.forEach((t) => t.abort());
} }
private isMouseEvent(event: Event): event is MouseEvent {
return event.type.startsWith("mouse");
}
} }

View File

@ -38,7 +38,7 @@ export default class VoipUserMapper {
return window.mxVoipUserMapper; return window.mxVoipUserMapper;
} }
private async userToVirtualUser(userId: string): Promise<string> { private async userToVirtualUser(userId: string): Promise<string | null> {
const results = await LegacyCallHandler.instance.sipVirtualLookup(userId); const results = await LegacyCallHandler.instance.sipVirtualLookup(userId);
if (results.length === 0 || !results[0].fields.lookup_success) return null; if (results.length === 0 || !results[0].fields.lookup_success) return null;
return results[0].userid; return results[0].userid;
@ -59,11 +59,11 @@ export default class VoipUserMapper {
if (!virtualUser) return null; if (!virtualUser) return null;
const virtualRoomId = await ensureVirtualRoomExists(MatrixClientPeg.get(), virtualUser, roomId); const virtualRoomId = await ensureVirtualRoomExists(MatrixClientPeg.get(), virtualUser, roomId);
MatrixClientPeg.get().setRoomAccountData(virtualRoomId, VIRTUAL_ROOM_EVENT_TYPE, { MatrixClientPeg.get().setRoomAccountData(virtualRoomId!, VIRTUAL_ROOM_EVENT_TYPE, {
native_room: roomId, native_room: roomId,
}); });
this.virtualToNativeRoomIdCache.set(virtualRoomId, roomId); this.virtualToNativeRoomIdCache.set(virtualRoomId!, roomId);
return virtualRoomId; return virtualRoomId;
} }
@ -121,8 +121,12 @@ export default class VoipUserMapper {
if (!LegacyCallHandler.instance.getSupportsVirtualRooms()) return; if (!LegacyCallHandler.instance.getSupportsVirtualRooms()) return;
const inviterId = invitedRoom.getDMInviter(); const inviterId = invitedRoom.getDMInviter();
if (!inviterId) {
logger.error("Could not find DM inviter for room id: " + invitedRoom.roomId);
}
logger.log(`Checking virtual-ness of room ID ${invitedRoom.roomId}, invited by ${inviterId}`); logger.log(`Checking virtual-ness of room ID ${invitedRoom.roomId}, invited by ${inviterId}`);
const result = await LegacyCallHandler.instance.sipNativeLookup(inviterId); const result = await LegacyCallHandler.instance.sipNativeLookup(inviterId!);
if (result.length === 0) { if (result.length === 0) {
return; return;
} }

View File

@ -21,11 +21,11 @@ import { MatrixClientPeg } from "./MatrixClientPeg";
import { _t } from "./languageHandler"; import { _t } from "./languageHandler";
export function usersTypingApartFromMeAndIgnored(room: Room): RoomMember[] { export function usersTypingApartFromMeAndIgnored(room: Room): RoomMember[] {
return usersTyping(room, [MatrixClientPeg.get().getUserId()].concat(MatrixClientPeg.get().getIgnoredUsers())); return usersTyping(room, [MatrixClientPeg.get().getUserId()!].concat(MatrixClientPeg.get().getIgnoredUsers()));
} }
export function usersTypingApartFromMe(room: Room): RoomMember[] { export function usersTypingApartFromMe(room: Room): RoomMember[] {
return usersTyping(room, [MatrixClientPeg.get().getUserId()]); return usersTyping(room, [MatrixClientPeg.get().getUserId()!]);
} }
/** /**
@ -36,7 +36,7 @@ export function usersTypingApartFromMe(room: Room): RoomMember[] {
* @returns {RoomMember[]} list of user objects who are typing. * @returns {RoomMember[]} list of user objects who are typing.
*/ */
export function usersTyping(room: Room, exclude: string[] = []): RoomMember[] { export function usersTyping(room: Room, exclude: string[] = []): RoomMember[] {
const whoIsTyping = []; const whoIsTyping: RoomMember[] = [];
const memberKeys = Object.keys(room.currentState.members); const memberKeys = Object.keys(room.currentState.members);
for (const userId of memberKeys) { for (const userId of memberKeys) {

View File

@ -120,7 +120,7 @@ function setRightPanel(state: IRightPanelCardState): void {
} }
} }
export function pendingVerificationRequestForUser(user: User | RoomMember): VerificationRequest { export function pendingVerificationRequestForUser(user: User | RoomMember): VerificationRequest | undefined {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
const dmRoom = findDMForUser(cli, user.userId); const dmRoom = findDMForUser(cli, user.userId);
if (dmRoom) { if (dmRoom) {