From 098df07c67ed41b7698b9cda0b0beaa2ecf525db Mon Sep 17 00:00:00 2001 From: Zoe Date: Mon, 30 Mar 2020 10:18:47 +0100 Subject: [PATCH] review feedback --- src/components/structures/RoomView.js | 4 ++-- src/components/views/rooms/RoomTile.js | 4 ++-- src/utils/ShieldUtils.ts | 6 +++--- test/utils/ShieldUtils-test.js | 20 ++++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 74572b962a..1a1f60c7bd 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -55,7 +55,7 @@ import RightPanelStore from "../../stores/RightPanelStore"; import {haveTileForEvent} from "../views/rooms/EventTile"; import RoomContext from "../../contexts/RoomContext"; import MatrixClientContext from "../../contexts/MatrixClientContext"; -import { shieldStatusForMembership } from '../../utils/ShieldUtils'; +import { shieldStatusForRoom } from '../../utils/ShieldUtils'; const DEBUG = false; let debuglog = function() {}; @@ -820,7 +820,7 @@ export default createReactClass({ /* At this point, the user has encryption on and cross-signing on */ this.setState({ - e2eStatus: await shieldStatusForMembership(this.context, room), + e2eStatus: await shieldStatusForRoom(this.context, room), }); }, diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js index 478d6703b4..0c913b32da 100644 --- a/src/components/views/rooms/RoomTile.js +++ b/src/components/views/rooms/RoomTile.js @@ -37,7 +37,7 @@ import E2EIcon from './E2EIcon'; import InviteOnlyIcon from './InviteOnlyIcon'; // eslint-disable-next-line camelcase import rate_limited_func from '../../../ratelimitedfunc'; -import { shieldStatusForMembership } from '../../../utils/ShieldUtils'; +import { shieldStatusForRoom } from '../../../utils/ShieldUtils'; export default createReactClass({ displayName: 'RoomTile', @@ -157,7 +157,7 @@ export default createReactClass({ /* At this point, the user has encryption on and cross-signing on */ this.setState({ - e2eStatus: await shieldStatusForMembership(cli, this.props.room), + e2eStatus: await shieldStatusForRoom(cli, this.props.room), }); }, diff --git a/src/utils/ShieldUtils.ts b/src/utils/ShieldUtils.ts index 3c7cae8c8d..ef2d475293 100644 --- a/src/utils/ShieldUtils.ts +++ b/src/utils/ShieldUtils.ts @@ -17,7 +17,7 @@ interface Room { roomId: string; } -export async function shieldStatusForMembership(client: Client, room: Room): Promise { +export async function shieldStatusForRoom(client: Client, room: Room): Promise { const members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId); const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId); @@ -33,8 +33,8 @@ export async function shieldStatusForMembership(client: Client, room: Room): Pro /* 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); diff --git a/test/utils/ShieldUtils-test.js b/test/utils/ShieldUtils-test.js index 973798fa4b..949f0ed42b 100644 --- a/test/utils/ShieldUtils-test.js +++ b/test/utils/ShieldUtils-test.js @@ -1,4 +1,4 @@ -import { shieldStatusForMembership } from '../../src/utils/ShieldUtils'; +import { shieldStatusForRoom } from '../../src/utils/ShieldUtils'; import DMRoomMap from '../../src/utils/DMRoomMap'; function mkClient(selfTrust) { @@ -55,7 +55,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@FF1:h", "@FF2:h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual("normal"); }); @@ -68,7 +68,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@TT2:h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); @@ -81,7 +81,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@FF2:h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); @@ -94,7 +94,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); @@ -107,7 +107,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@TT:h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); @@ -120,7 +120,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); }); @@ -140,7 +140,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); @@ -152,7 +152,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h", "@TT: h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); @@ -164,7 +164,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() { roomId: dm ? "DM" : "other", getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h", "@FT: h"].map((userId) => ({userId})), }; - const status = await shieldStatusForMembership(client, room); + const status = await shieldStatusForRoom(client, room); expect(status).toEqual(result); }); });