From aa5d55bbf28a5b21ce8c1f9ff1f8a481c14e54ce Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 14 Sep 2020 15:44:07 +0200 Subject: [PATCH] show when e2ee is enabled in timeline --- .../timeline/tiles/EncryptionEnabledTile.js | 28 +++++++++++++++++++ .../session/room/timeline/tilesCreator.js | 3 ++ 2 files changed, 31 insertions(+) create mode 100644 src/domain/session/room/timeline/tiles/EncryptionEnabledTile.js diff --git a/src/domain/session/room/timeline/tiles/EncryptionEnabledTile.js b/src/domain/session/room/timeline/tiles/EncryptionEnabledTile.js new file mode 100644 index 00000000..00bc6737 --- /dev/null +++ b/src/domain/session/room/timeline/tiles/EncryptionEnabledTile.js @@ -0,0 +1,28 @@ +/* +Copyright 2020 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import {SimpleTile} from "./SimpleTile.js"; + +export class EncryptionEnabledTile extends SimpleTile { + get shape() { + return "announcement"; + } + + get announcement() { + const senderName = this._entry.displayName || this._entry.sender; + return this.i18n`${senderName} has enabled end-to-end encryption`; + } +} diff --git a/src/domain/session/room/timeline/tilesCreator.js b/src/domain/session/room/timeline/tilesCreator.js index 567e9e7d..5f5593d5 100644 --- a/src/domain/session/room/timeline/tilesCreator.js +++ b/src/domain/session/room/timeline/tilesCreator.js @@ -21,6 +21,7 @@ import {LocationTile} from "./tiles/LocationTile.js"; import {RoomNameTile} from "./tiles/RoomNameTile.js"; import {RoomMemberTile} from "./tiles/RoomMemberTile.js"; import {EncryptedEventTile} from "./tiles/EncryptedEventTile.js"; +import {EncryptionEnabledTile} from "./tiles/EncryptionEnabledTile.js"; export function tilesCreator({room, ownUserId, clock}) { return function tilesCreator(entry, emitUpdate) { @@ -53,6 +54,8 @@ export function tilesCreator({room, ownUserId, clock}) { return new RoomMemberTile(options); case "m.room.encrypted": return new EncryptedEventTile(options); + case "m.room.encryption": + return new EncryptionEnabledTile(options); default: // unknown type not rendered return null;