From 371a5069af0c7515c42e4d4632621d9f231a5029 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Fri, 26 Apr 2024 16:44:06 +0200 Subject: [PATCH] Implement new "read only" room flag While still maintaining the ability to answer polls and send reactions in channels (when "read only" is false) --- src/assets/css/chat.scss | 2 + src/assets/icons/ic_eye.vue | 13 +++ src/assets/translations/en.json | 5 +- src/components/AudioLayout.vue | 4 +- src/components/Chat.vue | 7 +- src/components/CreateChannel.vue | 13 +-- src/components/RoomInfo.vue | 38 ++------- src/components/messages/MessageOperations.vue | 16 ++-- src/components/messages/MessageOutgoing.vue | 2 +- src/services/matrix.service.js | 80 +++++++++++++++---- 10 files changed, 112 insertions(+), 68 deletions(-) create mode 100644 src/assets/icons/ic_eye.vue diff --git a/src/assets/css/chat.scss b/src/assets/css/chat.scss index 7a9d668..4938df9 100644 --- a/src/assets/css/chat.scss +++ b/src/assets/css/chat.scss @@ -1052,6 +1052,8 @@ body { .option-text { font-size: 13 * $chat-text-size; + border-top: 1px solid #e1e1e1; + padding-top: 8px; } .option-title { diff --git a/src/assets/icons/ic_eye.vue b/src/assets/icons/ic_eye.vue new file mode 100644 index 0000000..6a1156c --- /dev/null +++ b/src/assets/icons/ic_eye.vue @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index fc99ded..67baacf 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -313,6 +313,7 @@ "export_room": "Export chat", "user_admin": "Administrator", "user_moderator": "Moderator", + "moderation": "Moderation", "experimental_features": "Experimental Features", "room_type": "Room type", "room_type_default": "Default", @@ -321,8 +322,8 @@ "file_mode": "File mode", "file_mode_info": "Switches the chat interface to a 'file drop' mode", "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", + "read_only_room": "Read Only", + "read_only_room_info": "Only admins and moderators are allowed to send to the room.", "message_retention": "Message History", "message_retention_info": "Messages sent within this time frame are viewable by anyone with the link.", "message_retention_none": "Off", diff --git a/src/components/AudioLayout.vue b/src/components/AudioLayout.vue index df629b3..d989815 100644 --- a/src/components/AudioLayout.vue +++ b/src/components/AudioLayout.vue @@ -147,7 +147,7 @@ export default { }, computed: { canRecordAudio() { - return !this.$matrix.currentRoomIsReadOnlyForUser && util.browserCanRecordAudio(); + return this.$matrix.userCanSendMessageInCurrentRoom && util.browserCanRecordAudio(); }, currentTime() { return util.formatDuration(this.info ? this.info.currentTime : 0); @@ -414,7 +414,7 @@ export default { }, micButtonClicked() { - if (this.$matrix.currentRoomIsReadOnlyForUser) { + if (!this.$matrix.userCanSendMessageInCurrentRoom) { this.showReadOnlyToast = true; setTimeout(() => { this.showReadOnlyToast = false; diff --git a/src/components/Chat.vue b/src/components/Chat.vue index 1e20735..0446698 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -44,7 +44,8 @@ isEmojiQuickReaction= true showMoreMessageOperations({event: selectedEvent, anchor: $event.anchor}) " :originalEvent="selectedEvent" :timelineSet="timelineSet" - :readOnlyRoom="$matrix.currentRoomIsReadOnlyForUser" + :userCanSendReactionAndAnswerPoll="$matrix.userCanSendReactionAndAnswerPollInCurrentRoom" + :userCanSendMessage="$matrix.userCanSendMessageInCurrentRoom" /> @@ -133,7 +134,7 @@ {{ typingMembersString }} - + -
{{ $t("message.not_allowed_to_send") }}
+
{{ $t("message.not_allowed_to_send") }}
-