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

@ -142,6 +142,7 @@
"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_user": "🕓 Messages older than {time} will be deleted from the history.",
"info_auto_join": "Welcome to {room}.\nYou are joining as {you}.",
"change": "Change"
},
"new_room": {

View file

@ -306,7 +306,14 @@ export default {
return roomName ? roomName : "";
},
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
.getPublicRoomInfo(this.roomId)
.then((room) => {

View file

@ -1,6 +1,14 @@
<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 -->
<div class="messageJoin">
<div v-else class="messageJoin">
{{ $t('message.user_joined',{user: eventSenderDisplayName(event)}) }}
</div>
</template>
@ -10,6 +18,19 @@ import messageMixin from "./messageMixin";
export default {
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>