diff --git a/src/assets/icons/ic_security-shield.vue b/src/assets/icons/ic_security-shield.vue new file mode 100644 index 0000000..1a75c57 --- /dev/null +++ b/src/assets/icons/ic_security-shield.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index 4e07c04..023072e 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -113,7 +113,8 @@ "join_public": "Anyone can join by opening this link: {link}.", "join_invite": "Only people you invite can join.", "info_permissions": "You can change ‘join permissions’ at any time in the room settings.", - "got_it": "Got it" + "got_it": "Got it", + "no_past_messages": "Welcome! For your security, past messages are not available." }, "new_room": { "new_room": "New Room", diff --git a/src/components/Chat.vue b/src/components/Chat.vue index 74f7ec7..2cd265a 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -42,7 +42,7 @@ -
+
@@ -69,6 +69,8 @@
+ + @@ -268,6 +270,7 @@ import ChatHeader from "./ChatHeader"; import VoiceRecorder from "./VoiceRecorder"; import RoomInfoBottomSheet from "./RoomInfoBottomSheet"; import CreatedRoomWelcomeHeader from "./CreatedRoomWelcomeHeader"; +import NoHistoryRoomWelcomeHeader from "./NoHistoryRoomWelcomeHeader.vue"; import MessageOperationsBottomSheet from "./MessageOperationsBottomSheet"; import StickerPickerBottomSheet from "./StickerPickerBottomSheet"; import BottomSheet from "./BottomSheet.vue"; @@ -317,6 +320,7 @@ export default { VoiceRecorder, RoomInfoBottomSheet, CreatedRoomWelcomeHeader, + NoHistoryRoomWelcomeHeader, MessageOperationsBottomSheet, StickerPickerBottomSheet, BottomSheet, @@ -529,6 +533,34 @@ export default { return util.useVoiceMode(this.room); }, }, + /** + * If we have no events and the room is encrypted, show info about this + * to the user. + */ + showNoHistoryRoomWelcomeHeader() { + return this.filteredEvents.length == 0 && this.room && this.$matrix.matrixClient.isRoomEncrypted(this.room.roomId); + }, + + filteredEvents() { + if (this.room && this.$matrix.matrixClient.isRoomEncrypted(this.room.roomId)) { + if (this.room.getHistoryVisibility() == "joined") { + // For encrypted rooms where history is set to "joined" we can't read old events. + // We might, however, have old status events from room creation etc. + // We filter out anything that happened before our own join event. + for (let idx = this.events.length - 1; idx >= 0; idx--) { + const e = this.events[idx]; + if (e.getType() == "m.room.member" && + e.getContent().membership == "join" && + (!e.getPrevContent() || e.getPrevContent().membership != "join") && + e.getStateKey() == this.$matrix.currentUserId) { + // Our own join event. + return this.events.slice(idx + 1); + } + } + } + } + return this.events; + } }, watch: { diff --git a/src/components/NoHistoryRoomWelcomeHeader.vue b/src/components/NoHistoryRoomWelcomeHeader.vue new file mode 100644 index 0000000..f94460e --- /dev/null +++ b/src/components/NoHistoryRoomWelcomeHeader.vue @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file