From 0f2e2ea069e9cdd5f05319370744aa354d450758 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 27 Mar 2020 11:58:54 +0000 Subject: [PATCH] Update shield display rules --- src/components/structures/RoomView.js | 8 +++++++- src/components/views/rooms/RoomTile.js | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 5fd5f42f78..dd453667e0 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -40,6 +40,7 @@ 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'; @@ -833,7 +834,12 @@ export default createReactClass({ /* Check all verified user devices. */ /* Don't alarm if no other users are verified */ - const targets = (verified.length > 0) ? [...verified, this.context.getUserId()] : verified; + const isDM = !!DMRoomMap.shared().getUserIdForRoomId(this.props.room.roomId); + const includeUser = (verified.length > 0) && // Don't alarm for self in rooms where nobody else is verified + !isDM && // Don't alarm for self in DMs with other users + (e2eMembers.length != 2) || // Don't alarm for self in 1:1 chats with other users + (e2eMembers.length == 1); // Do alarm for self if we're alone in a room + const targets = includeUser ? [...verified, this.context.getUserId()] : verified; for (const userId of targets) { const devices = await this.context.getStoredDevicesForUser(userId); const anyDeviceNotVerified = devices.some(({deviceId}) => { diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js index 0f44f5077a..6f9cd7f1be 100644 --- a/src/components/views/rooms/RoomTile.js +++ b/src/components/views/rooms/RoomTile.js @@ -167,7 +167,12 @@ export default createReactClass({ /* Check all verified user devices. */ /* Don't alarm if no other users are verified */ - const targets = (verified.length > 0) ? [...verified, cli.getUserId()] : verified; + const isDM = DMRoomMap.shared().getUserIdForRoomId(this.props.room.roomId); + const includeUser = (verified.length > 0) && // Don't alarm for self in rooms where nobody else is verified + !isDM && // Don't alarm for self in DMs with other users + (e2eMembers.length != 2) || // Don't alarm for self in 1:1 chats with other users + (e2eMembers.length == 1); // Do alarm for self if we're alone in a room + const targets = includeUser ? [...verified, cli.getUserId()] : verified; for (const userId of targets) { const devices = await cli.getStoredDevicesForUser(userId); const allDevicesVerified = devices.every(({deviceId}) => {