From 76ca3f8e70ff7a56328edff6d1a86d1107da7a99 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Thu, 16 Mar 2023 15:23:26 +0100 Subject: [PATCH] Experimental "read only" room support --- src/assets/config.json | 3 +- src/assets/css/chat.scss | 28 ++++++++++++++++++ src/assets/translations/en.json | 7 +++-- src/components/AudioLayout.vue | 25 ++++++++++------ src/components/Chat.vue | 11 ++++++- src/components/CreateRoom.vue | 30 +++++++++++++++++-- src/components/RoomInfo.vue | 31 ++++++++++++++++++-- src/services/matrix.service.js | 51 +++++++++++++++++++++++++++++++++ 8 files changed, 169 insertions(+), 17 deletions(-) diff --git a/src/assets/config.json b/src/assets/config.json index a816ef7..1d12445 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -40,5 +40,6 @@ } } ], - "experimental_voice_mode": true + "experimental_voice_mode": true, + "experimental_read_only_room": true } \ No newline at end of file diff --git a/src/assets/css/chat.scss b/src/assets/css/chat.scss index c0efad1..41f8419 100644 --- a/src/assets/css/chat.scss +++ b/src/assets/css/chat.scss @@ -295,6 +295,19 @@ body { } } + .input-area-read-only { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(white, 0.8); + display: flex; + align-items: center; + justify-content: center; + z-index: 40; + } + @media #{map-get($display-breakpoints, 'sm-and-down')} { position: fixed; bottom: 0px; @@ -1466,6 +1479,21 @@ body { .mic-button { z-index: 0; } + .mic-button.dimmed { + opacity: 0.5; + } + .toast-read-only { + position: fixed; + left: 10px; + right: 10px; + bottom: 10px; + background-color: rgba(black, 0.7); + display: flex; + align-items: center; + justify-content: center; + z-index: 40; + color: white; + } } .audio-layout.voice-recorder { diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index 6b6924e..b7ce9d2 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -82,7 +82,8 @@ "reply_poll": "Poll", "time_ago": "Today | Yesterday | {count} days ago", "outgoing_message_deleted_text": "You deleted this message.", - "incoming_message_deleted_text": "This message was deleted." + "incoming_message_deleted_text": "This message was deleted.", + "not_allowed_to_send": "Only admins and moderators are allowed to send to the room" }, "room": { "invitations": "You have no invitations | You have 1 invitation | You have {count} invitations", @@ -249,7 +250,9 @@ "experimental_features": "Experimental Features", "voice_mode": "Voice mode", "voice_mode_info": "Switches the chat interface to a 'listen and record' mode", - "download_chat": "Download chat" + "download_chat": "Download chat", + "read_only_room": "Read only room", + "read_only_room_info": "Only admins and moderators are allowed to send to the room" }, "room_info_sheet": { "this_room": "This room", diff --git a/src/components/AudioLayout.vue b/src/components/AudioLayout.vue index d3b9920..735573e 100644 --- a/src/components/AudioLayout.vue +++ b/src/components/AudioLayout.vue @@ -56,12 +56,14 @@
- + mic expand_more
+ +
{{ $t("message.not_allowed_to_send") }}
@@ -111,6 +113,7 @@ export default { playing: false, analyzer: null, analyzerDataArray: null, + showReadOnlyToast: false, }; }, mounted() { @@ -162,12 +165,7 @@ export default { }, computed: { canRecordAudio() { - if (this.room) { - const myUserId = this.$matrix.currentUserId; - const me = this.room.getMember(myUserId); - return me && me.powerLevelNorm > 0 && util.browserCanRecordAudio(); - } - return false; + return !this.$matrix.currentRoomIsReadOnlyForUser && util.browserCanRecordAudio(); }, currentTime() { return util.formatDuration(this.playTime); @@ -448,6 +446,17 @@ export default { } return null; }, + + micButtonClicked() { + if (this.$matrix.currentRoomIsReadOnlyForUser) { + this.showReadOnlyToast = true; + setTimeout(() => { + this.showReadOnlyToast = false; + }, 3000); + } else { + this.$emit('start-recording'); + } + } } }; diff --git a/src/components/Chat.vue b/src/components/Chat.vue index e95919f..a286a2c 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -6,7 +6,7 @@ :timelineSet="timelineSet" :readMarker="readMarker" :recordingMembers="typingMembers" - v-on:start-recording="showRecorder = true" + v-on:start-recording="setShowRecorder()" v-on:loadnext="handleScrolledToBottom(false)" v-on:loadprevious="handleScrolledToTop()" v-on:mark-read="sendRR" @@ -177,6 +177,7 @@ +
{{ $t("message.not_allowed_to_send") }}
{ this.chatContainer.parentElement.removeChild(div); }, 3000); + }, + setShowRecorder() { + if (this.canRecordAudio) { + this.showRecorder = true; + } else { + this.showNoRecordingAvailableDialog = true; + } } + }, }; diff --git a/src/components/CreateRoom.vue b/src/components/CreateRoom.vue index 85d08ea..ebf4288 100644 --- a/src/components/CreateRoom.vue +++ b/src/components/CreateRoom.vue @@ -43,13 +43,13 @@ v-on:keyup.enter="$refs.create.focus()" :disabled="step > steps.INITIAL" solo> -