keanu-weblite/src/components/LeaveRoomDialog.vue

119 lines
3.1 KiB
Vue
Raw Normal View History

<template>
2021-12-19 16:04:19 +02:00
<v-dialog
v-model="showDialog"
class="ma-0 pa-0"
2025-05-06 10:53:34 +02:00
:width="$vuetify.display.smAndUp ? '688px' : '95%'"
scroll-strategy="none"
2021-12-19 16:04:19 +02:00
>
<div class="dialog-content text-center">
<template v-if="roomJoinRule == 'public'">
<h1>👋</h1>
<h2 class="dialog-title">
{{
$t("leave.title_public", { user: $matrix.currentUserDisplayName })
}}
</h2>
2021-04-02 10:58:58 +02:00
<div
v-if="$matrix.currentUser.is_guest && lastRoom"
class="dialog-text"
>
2025-05-06 09:27:53 +02:00
<i18n-t keypath="leave.text_public_lastroom" tag="p">
<template v-slot:user>
<span>{{ $matrix.currentUserDisplayName }}</span>
</template>
<template v-slot:action>
<a @click.prevent="viewProfile">{{
$t("leave.create_account")
}}</a>
</template>
2025-05-06 09:27:53 +02:00
</i18n-t>
</div>
<div v-else class="dialog-text">{{ $t("leave.text_public") }}</div>
</template>
<template v-else>
<v-icon color="black" size="30">lock</v-icon>
<h2 class="dialog-title">
{{
$t("leave.title_invite", { user: $matrix.currentUserDisplayName })
}}
</h2>
<div class="dialog-text">{{ $t("leave.text_invite") }}</div>
</template>
<v-container fluid>
<v-row cols="12">
<v-col cols="6">
<v-btn
id="btn-back"
2025-05-09 10:17:59 +02:00
variant="flat"
block
class="text-button"
@click="showDialog = false"
>{{ $t("leave.go_back") }}</v-btn
>
</v-col>
<v-col cols="6" align="center">
<v-btn
id="btn-leave"
color="red"
2025-05-09 10:17:59 +02:00
variant="flat"
block
class="filled-button"
2021-04-02 10:58:58 +02:00
@click.stop="onLeaveRoom()"
>{{ $t("leave.leave") }}</v-btn
>
</v-col>
</v-row>
</v-container>
</div>
</v-dialog>
</template>
<script>
2025-05-08 11:52:39 +02:00
import RoomDialogBase from "./RoomDialogBase.vue";
import roomInfoMixin from "./roomInfoMixin";
export default {
name: "LeaveRoomDialog",
2025-05-08 11:52:39 +02:00
extends: RoomDialogBase,
data() {
return {
2021-04-02 10:58:58 +02:00
lastRoom: false,
};
},
2021-04-02 10:58:58 +02:00
methods: {
2025-05-08 11:52:39 +02:00
onOpenDialog() {
this.lastRoom = this.onlyJoinedToThisRoom();
},
2021-04-02 10:06:25 +02:00
onlyJoinedToThisRoom() {
const joinedRooms = this.$matrix.joinedRooms;
2021-04-02 10:58:58 +02:00
if (
joinedRooms &&
joinedRooms.length == 1 &&
joinedRooms[0].roomId == this.room.roomId
) {
2021-04-02 10:06:25 +02:00
return true;
}
return false;
2021-04-02 10:58:58 +02:00
},
2021-04-02 10:06:25 +02:00
2021-01-28 22:13:08 +01:00
onLeaveRoom() {
this.$matrix.leaveRoomAndNavigate(this.room.roomId)
.then(() => {
2021-04-02 10:58:58 +02:00
this.showDialog = false;
console.log("Left room");
})
.catch((err) => {
console.log("Error leaving", err);
});
},
viewProfile() {
this.showDialog = false;
this.$navigation.push({ name: "Profile" }, 1);
},
},
};
</script>
<style lang="scss">
@use "@/assets/css/chat.scss" as *;
2021-12-19 16:04:19 +02:00
</style>