From 6ca7a2040d43d96ab4949b919696778d2d774b01 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Thu, 27 May 2021 12:16:12 +0200 Subject: [PATCH] Simplify room creation and improve "room welcome header" for new rooms. Issue #127. --- src/assets/translations/en.json | 15 +++--- src/components/CreateRoom.vue | 45 ++++++++++++------ src/components/CreatedRoomWelcomeHeader.vue | 52 ++++++++++++++++++--- src/components/roomInfoMixin.js | 14 ++++++ src/services/matrix.service.js | 11 +++++ 5 files changed, 112 insertions(+), 25 deletions(-) diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index 660c89b..e47c8a6 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -11,7 +11,8 @@ "send": "Send", "back": "BACK", "login": "Login", - "logout": "Logout" + "logout": "Logout", + "new_room": "New Room" }, "message": { "you": "You", @@ -56,16 +57,19 @@ "room_welcome": { "welcome": "Welcome!", "info": "Here are a few things to know about your group:", - "join_public": "Anyone can join by opening this link: {link}", + "encrypted": "Messages are end-to-end encrypted.", + "room_history_is": "Room history is {type}.", + "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' and 'message history' at any time in the group settings.", "got_it": "Got it" }, "new_room": { - "new_room": "New Group", - "done": "Done", + "new_room": "New Room", + "create": "Create", "next": "Next", "name_room": "Name group", + "room_topic": "Add a description if you like", "join_permissions": "Join permissions", "set_join_permissions": "Set Join Permissions", "join_permissions_info": "These permissions determine how people can join the group and how easily others can be invited. They can be changed anytime.", @@ -161,8 +165,7 @@ }, "room_info_sheet": { "this_room": "This group", - "view_details": "View details", - "create_room": "Create group" + "view_details": "View details" }, "voice_recorder": { "swipe_to_cancel": "Swipe to cancel", diff --git a/src/components/CreateRoom.vue b/src/components/CreateRoom.vue index 4093743..03bd20b 100644 --- a/src/components/CreateRoom.vue +++ b/src/components/CreateRoom.vue @@ -13,7 +13,7 @@ arrow_back {{ $t("menu.back") }} - - + --> @@ -75,14 +75,16 @@ - - + + camera_alt - + + + + + {{$t('new_room.create')}} -
-
{{ $t("new_room.join_permissions") }}
+ +
{{ status }}
-
+
{ this.roomId = roomId; @@ -476,7 +495,7 @@ export default { (error.data && error.data.error) || error.message || error.toString(); - this.step = steps.NAME_SET; // revert + this.step = steps.INITIAL; // revert return null; }); }, diff --git a/src/components/CreatedRoomWelcomeHeader.vue b/src/components/CreatedRoomWelcomeHeader.vue index 7197e57..0b8620b 100644 --- a/src/components/CreatedRoomWelcomeHeader.vue +++ b/src/components/CreatedRoomWelcomeHeader.vue @@ -1,12 +1,28 @@ @@ -17,6 +33,30 @@ import roomInfoMixin from "./roomInfoMixin"; export default { name: "CreatedRoomWelcomeHeader", mixins: [roomInfoMixin], + computed: { + roomHistoryDescription() { + const visibility = this.$matrix.getRoomHistoryVisibility(this.room); + switch (visibility) { + case "world_readable": + return this.$t("room_welcome.room_history_is", { + type: this.$t("message.room_history_world_readable"), + }); + case "shared": + return this.$t("room_welcome.room_history_is", { + type: this.$t("message.room_history_shared"), + }); + case "invited": + return this.$t("room_welcome.room_history_is", { + type: this.$t("message.room_history_invited"), + }); + case "joined": + return this.$t("room_welcome.room_history_is", { + type: this.$t("message.room_history_joined"), + }); + } + return null; + }, + }, }; diff --git a/src/components/roomInfoMixin.js b/src/components/roomInfoMixin.js index 7c1ca30..83ad8d4 100644 --- a/src/components/roomInfoMixin.js +++ b/src/components/roomInfoMixin.js @@ -41,6 +41,13 @@ export default { return ""; }, + roomIsEncrypted() { + if (this.room) { + return this.$matrix.matrixClient.isRoomEncrypted(this.room.roomId); + } + return false; + }, + publicRoomLink() { if (this.room && this.roomJoinRule == "public") { return this.$router.getRoomLink( @@ -49,6 +56,13 @@ export default { } return null; }, + + roomHistory() { + if (this.room) { + return this.room.shouldEncryptForInvitedMembers() + } + return false; + } }, watch: { room: { diff --git a/src/services/matrix.service.js b/src/services/matrix.service.js index 00d4013..9f26ecf 100644 --- a/src/services/matrix.service.js +++ b/src/services/matrix.service.js @@ -440,6 +440,17 @@ export default { return null; }, + getRoomHistoryVisibility(room) { + if (room) { + const historyVisibility = room.currentState.getStateEvents( + "m.room.history_visibility", + "" + ); + return historyVisibility && historyVisibility.getContent().history_visibility; + } + return null; + }, + leaveRoom(roomId) { return this.matrixClient.leave(roomId, undefined) .then(() => {