From 0905bc34c09a7ae76bfe435d9e5af06ef568ac68 Mon Sep 17 00:00:00 2001 From: N Pex Date: Wed, 26 Apr 2023 11:04:05 +0000 Subject: [PATCH] Resolve "Reduce / hide the room creation status messages" --- README.md | 14 ++++++-- src/assets/config.json | 3 +- src/components/chatMixin.js | 69 +++++++++++++++++++++++++++++-------- 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1227016..5f4f3c6 100644 --- a/README.md +++ b/README.md @@ -38,13 +38,23 @@ npm run build npm run lint ``` -### Customize configuration +### Customize build configuration See [Configuration Reference](https://cli.vuejs.org/config/). ## Theming +You can do simple theming by setting values in the configuration file, see below. -# Sticker short codes - To enable sticker short codes, follow these steps: +## Configuration file +The app loads runtime configutation from the server at "./config.json" and merges that with the default values in "assets/config.json". + The following values can be set via the config file: + +* **logo** - An url or base64-encoded image data url that represents the app logotype. +* **accentColor** - The accent color of the app UI. +* **show_status_messages** - Whether to show only user joins/leaves and display name updates, or the full range of room status updates. Possible values are "never" (only the above), "moderators" (moderators will see all status updates) or "always" (everyone will see all status updates). Defaults to "always". + + +### Sticker short codes - To enable sticker short codes, follow these steps: * Run the "create sticker config" script using "npm run create-sticker-config " * Insert the resulting config blob into the "shortCodeStickers" value of the config file (assets/config.json) * Rearrange order of sticker packs by editing the config blob above. diff --git a/src/assets/config.json b/src/assets/config.json index 6886b8d..489ce76 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -44,5 +44,6 @@ } ], "experimental_voice_mode": true, - "experimental_read_only_room": true + "experimental_read_only_room": true, + "show_status_messages": "never" } \ No newline at end of file diff --git a/src/components/chatMixin.js b/src/components/chatMixin.js index d87a548..d1b0048 100644 --- a/src/components/chatMixin.js +++ b/src/components/chatMixin.js @@ -94,6 +94,15 @@ export default { CreatePollDialog, }, methods: { + showOnlyUserStatusMessages() { + // We say that if you can redact events, you are allowed to create polls. + // NOTE!!! This assumes that there is a property named "room" on THIS. + const me = this.room && this.room.getMember(this.$matrix.currentUserId); + let isModerator = + me && this.room.currentState && this.room.currentState.hasSufficientPowerLevelFor("redact", me.powerLevel); + const show = this.$config.show_status_messages; + return show === "never" || (show === "moderators" && !isModerator) + }, showDayMarkerBeforeEvent(event) { const idx = this.events.indexOf(event); if (idx <= 0) { @@ -132,10 +141,12 @@ export default { return ContactKicked; } return ContactLeave; - } else if (event.getContent().membership == "invite") { - return ContactInvited; - } else if (event.getContent().membership == "ban") { - return ContactBanned; + } else if (!this.showOnlyUserStatusMessages()) { + if (event.getContent().membership == "invite") { + return ContactInvited; + } else if (event.getContent().membership == "ban") { + return ContactBanned; + } } break; @@ -203,34 +214,64 @@ export default { } case "m.room.create": - return RoomCreated; + if (!this.showOnlyUserStatusMessages()) { + return RoomCreated; + } + break; case "m.room.canonical_alias": - return RoomAliased; + if (!this.showOnlyUserStatusMessages()) { + return RoomAliased; + } + break; case "m.room.name": - return RoomNameChanged; + if (!this.showOnlyUserStatusMessages()) { + return RoomNameChanged; + } + break; case "m.room.topic": - return RoomTopicChanged; + if (!this.showOnlyUserStatusMessages()) { + return RoomTopicChanged; + } + break; case "m.room.avatar": - return RoomAvatarChanged; + if (!this.showOnlyUserStatusMessages()) { + return RoomAvatarChanged; + } + break; case "m.room.history_visibility": - return RoomHistoryVisibility; + if (!this.showOnlyUserStatusMessages()) { + return RoomHistoryVisibility; + } + break; case "m.room.join_rules": - return RoomJoinRules; + if (!this.showOnlyUserStatusMessages()) { + return RoomJoinRules; + } + break; case "m.room.power_levels": - return RoomPowerLevelsChanged; + if (!this.showOnlyUserStatusMessages()) { + return RoomPowerLevelsChanged; + } + break; case "m.room.guest_access": - return RoomGuestAccessChanged; + if (!this.showOnlyUserStatusMessages()) { + return RoomGuestAccessChanged; + } + break; case "m.room.encryption": - return RoomEncrypted; + if (!this.showOnlyUserStatusMessages()) { + return RoomEncrypted; + } + break; case "m.poll.start": case "org.matrix.msc3381.poll.start":