Client side or purge room

Redirect to "goodbye" view. Issue #118.
This commit is contained in:
N-Pex 2021-07-05 18:16:21 +02:00
parent e324355b63
commit d39357401b
8 changed files with 193 additions and 60 deletions

View file

@ -4,27 +4,35 @@
<template v-if="roomJoinRule == 'public'">
<h1>👋</h1>
<h2 class="dialog-title">
{{$t('leave.title_public',{user: $matrix.currentUserDisplayName})}}
{{
$t("leave.title_public", { user: $matrix.currentUserDisplayName })
}}
</h2>
<div
v-if="$matrix.currentUser.is_guest && lastRoom"
class="dialog-text"
>
<i18n path="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>
<i18n path="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>
</i18n>
</div>
<div v-else class="dialog-text">{{$t('leave.text_public')}}</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>
<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">
@ -35,7 +43,7 @@
block
class="text-button"
@click="showDialog = false"
>{{$t('leave.go_back')}}</v-btn
>{{ $t("leave.go_back") }}</v-btn
>
</v-col>
<v-col cols="6" align="center">
@ -45,7 +53,7 @@
block
class="filled-button"
@click.stop="onLeaveRoom()"
>{{$t('leave.leave')}}</v-btn
>{{ $t("leave.leave") }}</v-btn
>
</v-col>
</v-row>

View file

@ -2,6 +2,7 @@
<v-dialog v-model="showDialog" v-show="room" class="ma-0 pa-0" width="80%">
<div class="dialog-content text-center">
<template>
<v-img contain height="28" src="@/assets/icons/trash_black.svg" />
<h2 class="dialog-title">{{ $t("purge_room.title") }}</h2>
<div class="dialog-text">
{{ $t("purge_room.info") }}
@ -101,4 +102,4 @@ export default {
<style lang="scss">
@import "@/assets/css/chat.scss";
</style>
</style>

View file

@ -1,49 +1,130 @@
<template>
<transition name="slow-fade">
<div
v-if="mounted"
style="
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 100;
background-color: black;
align-items: center;
justify-content: center;
padding: 40px;
"
class="text-center d-flex flex-column"
>
<div class="quote white--text">{{ quote }}</div>
<div class="author white--text mt-4">- {{ author }}</div>
<v-btn color="white" text class="close" @click.stop="closeBrowserTab">Close your browser tab</v-btn>
</div>
</transition>
<div>
<transition name="slow-fade">
<div
v-if="mounted"
style="
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 100;
background-color: black;
align-items: center;
justify-content: center;
padding: 40px;
"
class="text-center d-flex flex-column"
>
<div v-if="roomWasPurged" style="width: 28px">
<v-img src="@/assets/icons/trash.svg" />
</div>
<h2 v-if="roomWasPurged" class="white--text mt-2 mb-8">
{{ $t("goodbye.room_deleted") }}
</h2>
<div class="quote white--text">{{ quote }}</div>
<div class="author white--text mt-4">- {{ author }}</div>
<v-btn
v-if="joinedToAnyRoom"
color="white"
text
class="close"
@click.stop="viewOtherRooms"
>{{ $t("goodbye.view_other_rooms") }}</v-btn
>
<v-btn
v-else
color="white"
text
class="close"
@click.stop="closeBrowserTab"
>{{ $t("goodbye.close_tab") }}</v-btn
>
</div>
</transition>
<!-- PROFILE INFO IN TOP RIGHT -->
<transition name="slow-fade">
<div
v-if="mounted"
style="
position: fixed;
top: 24px;
right: 24px;
z-index: 101;
padding: 10px 20px;
height: 50px;
border-radius: 25px;
background-color: #242424;
"
>
<div class="d-inline-block me-2 white--text">
{{ $t("profile_info_popup.you_are") }}
</div>
<div
v-if="$matrix.currentUser.is_guest"
class="d-inline-block me-2 white--text"
>
<i18n path="profile_info_popup.identity_temporary" tag="span">
<template v-slot:displayName>
<b>{{ displayName }}</b>
</template>
</i18n>
</div>
<div v-else class="d-inline-block me-2 white--text">
<i18n path="profile_info_popup.identity" tag="span">
<template v-slot:displayName>
<b>{{ displayName }}</b>
</template>
</i18n>
</div>
<v-avatar
class="avatar-32 d-inline-block"
size="32"
color="#e0e0e0"
@click.stop="showProfileInfo = true"
>
<img v-if="userAvatar" :src="userAvatar" />
<span v-else class="white--text">{{ userAvatarLetter }}</span>
</v-avatar>
</div>
</transition>
</div>
</template>
<script>
import profileInfoMixin from "./profileInfoMixin";
export default {
name: "QuoteView",
mixins: [profileInfoMixin],
props: {
roomWasPurged: {
type: Boolean,
default: function () {
return false;
},
},
},
data() {
return {
mounted: false,
quote: "",
author: "",
}
};
},
mounted() {
var quotes;
try {
quotes = require('@/assets/quotes/' + this.$i18n.locale + '/quotes');
} catch (error) {
console.error("No quotes for language");
quotes = undefined;
quotes = require("@/assets/quotes/" + this.$i18n.locale + "/quotes");
} catch (error) {
console.error("No quotes for language");
quotes = undefined;
}
if (!quotes) {
quotes = require('@/assets/quotes/en/quotes'); // Default fallback
quotes = require("@/assets/quotes/en/quotes"); // Default fallback
}
const n = quotes.quotes.length;
const quote = quotes.quotes[Math.floor(Math.random() * n)];
@ -52,12 +133,24 @@ export default {
this.mounted = true;
},
computed: {
/**
* Return true if we are still joined to any rooms
*/
joinedToAnyRoom() {
const joinedRooms = this.$matrix.joinedRooms;
return joinedRooms.length > 0;
},
},
methods: {
closeBrowserTab() {
window.location.href="about:blank";
}
}
window.location.href = "about:blank";
},
viewOtherRooms() {
this.$navigation.push({ name: "Home" }, -1);
},
},
};
</script>
@ -80,5 +173,4 @@ export default {
.slow-fade-enter, .slow-fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0;
}
</style>