Add "auto_join_rooms" flag

This commit is contained in:
N-Pex 2024-07-22 10:38:07 +02:00
parent b646b1c8ad
commit 66ea1c4fdc
4 changed files with 32 additions and 3 deletions

View file

@ -53,7 +53,7 @@ The app loads runtime configutation from the server at "./config.json" and merge
* **accentColor** - The accent color of the app UI. Use a HTML-style color value string, like "#ff0080". * **accentColor** - The accent color of the app UI. Use a HTML-style color value string, like "#ff0080".
* **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". * **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".
* **maxSizeAutoDownloads** - Attachments smaller than this will be auto downloaded. Default is 10Mb. * **maxSizeAutoDownloads** - Attachments smaller than this will be auto downloaded. Default is 10Mb.
* **auto_join_rooms** - Whether to show the normal "join" screen or just auto join the user to the room link. Default to false.
### Sticker short codes - To enable sticker short codes, follow these steps: ### Sticker short codes - To enable sticker short codes, follow these steps:
* Run the "create sticker config" script using "npm run create-sticker-config <path-to-sticker-packs>" * Run the "create sticker config" script using "npm run create-sticker-config <path-to-sticker-packs>"

View file

@ -142,6 +142,7 @@
"join_channel": "All set! Invite people to join you: {link}", "join_channel": "All set! Invite people to join you: {link}",
"info_retention": "🕓 Messages sent within {time} are viewable by anyone with the link.", "info_retention": "🕓 Messages sent within {time} are viewable by anyone with the link.",
"info_retention_user": "🕓 Messages older than {time} will be deleted from the history.", "info_retention_user": "🕓 Messages older than {time} will be deleted from the history.",
"info_auto_join": "Welcome to {room}.\nYou are joining as {you}.",
"change": "Change" "change": "Change"
}, },
"new_room": { "new_room": {

View file

@ -306,7 +306,14 @@ export default {
return roomName ? roomName : ""; return roomName ? roomName : "";
}, },
getRoomInfo() { getRoomInfo() {
if (this.roomId.startsWith("#")) { if (this.$config.auto_join_rooms) {
// Auto-join room
this.waitingForRoomCreation = true;
this.$nextTick(() => {
this.handleJoin();
});
}
else if (this.roomId.startsWith("#")) {
this.$matrix this.$matrix
.getPublicRoomInfo(this.roomId) .getPublicRoomInfo(this.roomId)
.then((room) => { .then((room) => {

View file

@ -1,6 +1,14 @@
<template> <template>
<div v-if="$config.auto_join_rooms && !roomCreatedByYou() && event.getSender() == $matrix.currentUserId" class="created-room-welcome-header" style="white-space: pre-line;">
{{ $t('room_welcome.info_auto_join',{room: room ? room.name : "",you: $matrix.currentUserDisplayName}) }}
<div class="ma-0">
<a href="#" text @click.prevent="viewProfile">
{{ $t("room_welcome.change") }}
</a>
</div>
</div>
<!-- Contact joined the chat --> <!-- Contact joined the chat -->
<div class="messageJoin"> <div v-else class="messageJoin">
{{ $t('message.user_joined',{user: eventSenderDisplayName(event)}) }} {{ $t('message.user_joined',{user: eventSenderDisplayName(event)}) }}
</div> </div>
</template> </template>
@ -10,6 +18,19 @@ import messageMixin from "./messageMixin";
export default { export default {
mixins: [messageMixin], mixins: [messageMixin],
methods: {
viewProfile() {
this.$navigation.push({ name: "Profile" }, 1);
},
roomCreatedByYou() {
const createEvent = this.room && this.room.currentState.getStateEvents("m.room.create", "");
if (createEvent) {
const creatorId = createEvent.getContent().creator;
return (creatorId == this.$matrix.currentUserId);
}
return false;
},
}
}; };
</script> </script>