From 5b7e7f49d1cbc4733769f16a042b0a383d21c6c5 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 27 Mar 2020 13:50:03 +0000 Subject: [PATCH] lint --- src/components/structures/RoomView.js | 1 - src/utils/ShieldUtils.ts | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 7ce50348c9..74572b962a 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -40,7 +40,6 @@ import rate_limited_func from '../../ratelimitedfunc'; import * as ObjectUtils from '../../ObjectUtils'; import * as Rooms from '../../Rooms'; import eventSearch from '../../Searching'; -import DMRoomMap from '../../utils/DMRoomMap'; import {isOnlyCtrlOrCmdKeyEvent, Key} from '../../Keyboard'; diff --git a/src/utils/ShieldUtils.ts b/src/utils/ShieldUtils.ts index 407dae8e97..30b1dab7fc 100644 --- a/src/utils/ShieldUtils.ts +++ b/src/utils/ShieldUtils.ts @@ -12,12 +12,17 @@ interface Client { } } -export async function shieldStatusForMembership(client: Client, room) { +interface Room { + getEncryptionTargetMembers: () => Promise<[{userId: string}]>; + roomId: string; +} + +export async function shieldStatusForMembership(client: Client, room: Room) { const members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId); const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId); - const verified = []; - const unverified = []; + const verified: string[] = []; + const unverified: string[] = []; members.filter((userId) => userId !== client.getUserId()) .forEach((userId) => { (client.checkUserTrust(userId).isCrossSigningVerified() ? @@ -28,8 +33,8 @@ export async function shieldStatusForMembership(client: Client, room) { /* Don't alarm if no other users are verified */ const includeUser = (verified.length > 0) && // Don't alarm for self in rooms where nobody else is verified !inDMMap && // Don't alarm for self in DMs with other users - (members.length != 2) || // Don't alarm for self in 1:1 chats with other users - (members.length == 1); // Do alarm for self if we're alone in a room + (members.length !== 2) || // Don't alarm for self in 1:1 chats with other users + (members.length === 1); // Do alarm for self if we're alone in a room const targets = includeUser ? [...verified, client.getUserId()] : verified; for (const userId of targets) { const devices = await client.getStoredDevicesForUser(userId);