2020-11-25 10:02:24 +01:00
|
|
|
<template>
|
2021-12-19 16:04:19 +02:00
|
|
|
<div class="join-room" v-if="!waitingForInfo && !waitingForMembership">
|
|
|
|
|
<div class="join-enter-room">
|
|
|
|
|
<div>
|
|
|
|
|
<div class="text-center">
|
|
|
|
|
<v-avatar class="join-avatar">
|
|
|
|
|
<v-img v-if="roomAvatar" :src="roomAvatar" />
|
|
|
|
|
<span v-else class="white--text headline">
|
2022-12-12 16:10:53 +00:00
|
|
|
{{ roomName.substring(0, 1).toUpperCase() }}
|
2021-12-19 16:04:19 +02:00
|
|
|
</span>
|
|
|
|
|
</v-avatar>
|
|
|
|
|
<div class="join-welcome font-weight-bold">
|
2022-12-12 16:10:53 +00:00
|
|
|
{{ roomId && roomId.startsWith("@") ? $t("join.title_user") : $t("join.title") }}
|
2021-12-19 16:04:19 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="join-title">
|
2023-05-23 16:29:17 +02:00
|
|
|
{{ roomDisplayName || roomName }}
|
2021-12-19 16:04:19 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-12-12 16:10:53 +00:00
|
|
|
<hr class="my-10 join-line" />
|
2023-01-09 14:21:08 +00:00
|
|
|
<div class="font-weight-black mb-4" v-if="!currentUser">Choose a name to use.</div>
|
2020-11-25 10:02:24 +01:00
|
|
|
|
2021-03-03 15:41:15 +01:00
|
|
|
<v-row v-if="canEditProfile">
|
2023-01-09 14:21:08 +00:00
|
|
|
<v-col cols="10" sm="7" class="py-0">
|
|
|
|
|
<v-select
|
|
|
|
|
ref="avatar"
|
|
|
|
|
:items="availableAvatars"
|
|
|
|
|
cache-items
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
@change="selectAvatar"
|
|
|
|
|
:value="availableAvatars[0]"
|
|
|
|
|
single-line
|
|
|
|
|
autofocus
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:selection>
|
|
|
|
|
<v-text-field
|
|
|
|
|
background-color="transparent"
|
|
|
|
|
solo
|
|
|
|
|
flat
|
|
|
|
|
hide-details
|
|
|
|
|
@click.native.stop="
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
v-model="selectedProfile.name"
|
|
|
|
|
></v-text-field>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:item="data">
|
|
|
|
|
<v-avatar size="32">
|
|
|
|
|
<v-img :src="data.item.image" />
|
|
|
|
|
</v-avatar>
|
|
|
|
|
<div class="ms-2">{{ data.item.name }}</div>
|
|
|
|
|
</template>
|
|
|
|
|
</v-select>
|
2022-05-11 14:08:45 +00:00
|
|
|
<v-checkbox
|
|
|
|
|
id="chk-remember-me"
|
|
|
|
|
class="mt-0"
|
|
|
|
|
v-model="rememberMe"
|
|
|
|
|
:label="$t('join.remember_me')"
|
|
|
|
|
@change="onRememberMe"
|
|
|
|
|
/>
|
2021-12-19 16:04:19 +02:00
|
|
|
</v-col>
|
2023-01-09 14:21:08 +00:00
|
|
|
<v-col cols="2" sm="5" class="py-0">
|
|
|
|
|
<v-avatar @click="showAvatarPicker">
|
2021-04-13 19:17:07 +02:00
|
|
|
<v-img v-if="selectedProfile" :src="selectedProfile.image" />
|
2021-01-20 09:42:13 +01:00
|
|
|
</v-avatar>
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
2021-12-19 16:04:19 +02:00
|
|
|
<v-row v-else class="text-center">
|
2021-03-03 15:41:15 +01:00
|
|
|
<v-col>
|
2021-06-29 11:55:53 +02:00
|
|
|
{{ $t("join.joining_as") }}
|
2022-02-23 11:52:09 +00:00
|
|
|
<div class="d-inline-block">
|
|
|
|
|
<v-avatar color="#e0e0e0">
|
2021-03-12 14:57:36 +01:00
|
|
|
<v-img v-if="userAvatar" :src="userAvatar" />
|
2022-12-12 16:10:53 +00:00
|
|
|
<span v-else class="white--text headline">{{ userAvatarLetter }}</span>
|
2021-03-12 14:57:36 +01:00
|
|
|
</v-avatar>
|
2021-03-03 15:41:15 +01:00
|
|
|
</div>
|
|
|
|
|
{{ userDisplayName }}
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
2020-12-16 16:36:23 +01:00
|
|
|
|
2023-04-04 14:30:50 +00:00
|
|
|
<interactive-auth ref="interactiveAuth" />
|
|
|
|
|
|
2023-06-08 13:25:02 +00:00
|
|
|
<v-btn id="btn-join" class="btn-dark" :disabled="room && room.selfMembership == 'ban'" large @click.stop="handleJoin" :loading="loading" v-if="!currentUser">{{
|
2022-12-12 16:10:53 +00:00
|
|
|
roomId && roomId.startsWith("@") ? $t("join.enter_room_user") : $t("join.enter_room")
|
|
|
|
|
}}</v-btn>
|
2023-06-08 13:25:02 +00:00
|
|
|
<v-btn id="btn-join" class="btn-dark" :disabled="room && room.selfMembership == 'ban'" large block @click.stop="handleJoin" :loading="loading" v-else>{{
|
2022-12-12 16:10:53 +00:00
|
|
|
roomId && roomId.startsWith("@") ? $t("join.join_user") : $t("join.join")
|
|
|
|
|
}}</v-btn>
|
2020-12-16 15:57:44 +01:00
|
|
|
|
2021-12-19 16:04:19 +02:00
|
|
|
<div v-if="loadingMessage" class="text-center">{{ loadingMessage }}</div>
|
2023-06-08 13:25:02 +00:00
|
|
|
<div v-if="room && room.selfMembership == 'ban'" class="text-center">{{ $t("join.you_have_been_banned") }}</div>
|
2021-12-19 16:04:19 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-11-25 10:02:24 +01:00
|
|
|
|
2023-01-09 14:21:08 +00:00
|
|
|
<input
|
|
|
|
|
id="room-avatar-picker"
|
|
|
|
|
ref="avatar"
|
|
|
|
|
type="file"
|
|
|
|
|
name="avatar"
|
|
|
|
|
@change="handlePickedAvatar($event)"
|
|
|
|
|
accept="image/*"
|
|
|
|
|
class="d-none"
|
|
|
|
|
/>
|
|
|
|
|
|
2021-12-19 16:04:19 +02:00
|
|
|
<div class="join-lang">
|
|
|
|
|
<h3 class="mb-2">{{ $t("profile.select_language") }}</h3>
|
|
|
|
|
<v-row class="align-center">
|
2022-02-11 07:24:28 +00:00
|
|
|
<v-col v-for="lang in activeLanguage" :key="lang.value">
|
|
|
|
|
<span class="active">{{ lang.text }}</span>
|
|
|
|
|
</v-col>
|
2022-12-12 16:10:53 +00:00
|
|
|
<v-col v-for="(lang, key) in getDisplayLanguage.slice(0, 3)" :key="key">
|
2022-02-11 07:24:28 +00:00
|
|
|
<button class="inactive" @click="updateLanguage(lang.value)">{{ lang.text }}</button>
|
2021-12-19 16:04:19 +02:00
|
|
|
</v-col>
|
|
|
|
|
<v-col>
|
2022-12-12 16:10:53 +00:00
|
|
|
<v-btn id="btn-select-language" class="language-more" @click="showSelectLanguageDialog = true">
|
|
|
|
|
<v-icon>language</v-icon><v-icon>more_horiz</v-icon>
|
2021-12-19 16:04:19 +02:00
|
|
|
</v-btn>
|
|
|
|
|
</v-col>
|
2022-12-12 16:10:53 +00:00
|
|
|
<SelectLanguageDialog v-model="showSelectLanguageDialog" v-on:close="showSelectLanguageDialog = false" />
|
2021-12-19 16:04:19 +02:00
|
|
|
</v-row>
|
|
|
|
|
</div>
|
2020-12-16 15:57:44 +01:00
|
|
|
|
2021-12-19 16:04:19 +02:00
|
|
|
<div class="d-flex justify-center align-center mt-9">
|
|
|
|
|
<div class="mr-2">
|
2023-04-26 11:39:32 +02:00
|
|
|
<img :src="logotype" width="32" height="32" contain class="d-inline" />
|
2021-12-19 16:04:19 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<strong>{{ $t("project.name") }}</strong>
|
|
|
|
|
{{ $t("project.tag_line") }}
|
|
|
|
|
</div>
|
2020-11-25 10:02:24 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-08-30 10:50:45 +02:00
|
|
|
|
|
|
|
|
<!-- Loading indicator -->
|
|
|
|
|
<v-container
|
|
|
|
|
v-else
|
|
|
|
|
fluid
|
|
|
|
|
fill-height
|
2023-08-31 09:51:27 +02:00
|
|
|
class="loading-indicator transparent"
|
2023-08-30 10:50:45 +02:00
|
|
|
>
|
|
|
|
|
<v-row align="center" justify="center">
|
|
|
|
|
<v-col class="text-center">
|
2023-08-31 09:51:27 +02:00
|
|
|
<interactive-auth ref="interactiveAuth" v-if="waitingForRoomCreation" />
|
|
|
|
|
<v-progress-circular v-else
|
2023-08-30 10:50:45 +02:00
|
|
|
indeterminate
|
|
|
|
|
color="primary"
|
|
|
|
|
></v-progress-circular>
|
|
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
|
|
|
|
</v-container>
|
2020-11-25 10:02:24 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-01-12 11:26:01 +01:00
|
|
|
import util from "../plugins/utils";
|
2023-04-04 14:30:50 +00:00
|
|
|
import InteractiveAuth from './InteractiveAuth.vue';
|
2021-12-19 16:04:19 +02:00
|
|
|
import LanguageMixin from "./languageMixin";
|
2022-05-11 14:08:45 +00:00
|
|
|
import rememberMeMixin from "./rememberMeMixin";
|
2023-04-26 11:39:32 +02:00
|
|
|
import logoMixin from "./logoMixin";
|
2021-12-19 16:04:19 +02:00
|
|
|
import SelectLanguageDialog from "./SelectLanguageDialog.vue";
|
2020-11-25 10:02:24 +01:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Join",
|
2023-04-26 11:39:32 +02:00
|
|
|
mixins: [LanguageMixin, rememberMeMixin, logoMixin],
|
2021-12-19 16:04:19 +02:00
|
|
|
components: {
|
|
|
|
|
SelectLanguageDialog,
|
2023-04-04 14:30:50 +00:00
|
|
|
InteractiveAuth
|
2021-12-19 16:04:19 +02:00
|
|
|
},
|
2020-11-25 10:02:24 +01:00
|
|
|
data() {
|
|
|
|
|
return {
|
2020-12-16 15:57:44 +01:00
|
|
|
roomName: null,
|
|
|
|
|
roomAvatar: null,
|
2020-11-25 10:02:24 +01:00
|
|
|
loading: false,
|
|
|
|
|
loadingMessage: null,
|
2021-01-08 11:07:02 +01:00
|
|
|
waitingForInfo: true,
|
|
|
|
|
waitingForMembership: false,
|
2023-08-31 09:51:27 +02:00
|
|
|
waitingForRoomCreation: false,
|
2021-01-20 09:42:13 +01:00
|
|
|
availableAvatars: [],
|
2021-02-03 22:21:53 +01:00
|
|
|
selectedProfile: null,
|
2021-12-19 16:04:19 +02:00
|
|
|
showEditDisplaynameDialog: false,
|
|
|
|
|
showSelectLanguageDialog: false,
|
2020-11-25 10:02:24 +01:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
currentUser() {
|
|
|
|
|
return this.$store.state.auth.user;
|
|
|
|
|
},
|
2021-01-28 22:13:08 +01:00
|
|
|
room() {
|
|
|
|
|
return this.$matrix.currentRoom;
|
|
|
|
|
},
|
|
|
|
|
roomId() {
|
|
|
|
|
if (this.room) {
|
|
|
|
|
return this.room.roomId;
|
|
|
|
|
}
|
|
|
|
|
return this.$matrix.currentRoomId;
|
|
|
|
|
},
|
|
|
|
|
roomAliasOrId() {
|
|
|
|
|
if (this.room) {
|
|
|
|
|
return this.room.getCanonicalAlias() || this.room.roomId;
|
|
|
|
|
}
|
|
|
|
|
return this.$matrix.currentRoomId;
|
|
|
|
|
},
|
2021-02-03 22:21:53 +01:00
|
|
|
|
2021-03-03 15:41:15 +01:00
|
|
|
canEditProfile() {
|
|
|
|
|
// If we have an account already, we can't edit profile here (need to go into profile view)
|
|
|
|
|
if (this.currentUser) {
|
|
|
|
|
return false;
|
2021-02-03 22:21:53 +01:00
|
|
|
}
|
2021-03-03 15:41:15 +01:00
|
|
|
return true;
|
2021-02-03 22:21:53 +01:00
|
|
|
},
|
|
|
|
|
|
2021-01-29 21:41:43 +01:00
|
|
|
userDisplayName() {
|
2021-04-01 10:11:30 +02:00
|
|
|
return this.$matrix.currentUserDisplayName;
|
2021-01-29 21:41:43 +01:00
|
|
|
},
|
2021-02-03 22:21:53 +01:00
|
|
|
|
2021-01-29 21:41:43 +01:00
|
|
|
userAvatar() {
|
|
|
|
|
if (!this.$matrix.userAvatar) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-12-12 16:10:53 +00:00
|
|
|
return this.$matrix.matrixClient.mxcUrlToHttp(this.$matrix.userAvatar, 80, 80, "scale", true);
|
2021-01-29 21:41:43 +01:00
|
|
|
},
|
2021-03-03 15:41:15 +01:00
|
|
|
|
|
|
|
|
userAvatarLetter() {
|
2021-03-10 13:40:32 +01:00
|
|
|
if (!this.currentUser || !this.currentUser.userId) {
|
2021-03-03 15:41:15 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
2022-12-12 16:10:53 +00:00
|
|
|
return (this.currentUserDisplayName || this.currentUser.userId.substring(1)).substring(0, 1).toUpperCase();
|
2021-03-12 14:57:36 +01:00
|
|
|
},
|
2022-02-11 07:24:28 +00:00
|
|
|
getDisplayLanguage() {
|
|
|
|
|
let displayLanguages = [...this.getLanguages()];
|
2022-12-12 16:10:53 +00:00
|
|
|
return displayLanguages.filter((lang) => lang.display && lang.value !== this.$i18n.locale);
|
2022-02-11 07:24:28 +00:00
|
|
|
},
|
|
|
|
|
activeLanguage() {
|
2022-12-12 16:10:53 +00:00
|
|
|
let activeLanguages = [...this.getLanguages()];
|
|
|
|
|
return activeLanguages.filter((lang) => lang.value === this.$i18n.locale);
|
|
|
|
|
},
|
2023-05-23 16:29:17 +02:00
|
|
|
roomDisplayName() {
|
|
|
|
|
// If there is a display name in to invite link, use that!
|
|
|
|
|
try {
|
|
|
|
|
return new URL(location.href).searchParams.get('roomName');
|
|
|
|
|
} catch(ignoredError) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-19 17:38:54 +02:00
|
|
|
},
|
2021-01-28 22:13:08 +01:00
|
|
|
watch: {
|
|
|
|
|
roomId: {
|
|
|
|
|
immediate: true,
|
2021-01-29 21:41:43 +01:00
|
|
|
handler(value, oldVal) {
|
|
|
|
|
if (!value || (value && value == oldVal)) {
|
2021-01-28 22:13:08 +01:00
|
|
|
return; // No change.
|
|
|
|
|
}
|
2022-12-12 16:10:53 +00:00
|
|
|
console.log("Join: Current room changed to " + (value ? value : "null"));
|
|
|
|
|
this.roomName = this.removeHomeServer(this.roomId);
|
2021-03-12 14:57:36 +01:00
|
|
|
|
|
|
|
|
this.waitingForInfo = true;
|
2023-08-31 09:51:27 +02:00
|
|
|
this.waitingForRoomCreation = false;
|
2021-03-12 14:57:36 +01:00
|
|
|
const self = this;
|
2021-06-29 11:55:53 +02:00
|
|
|
this.waitingForMembership = true;
|
2021-03-12 14:57:36 +01:00
|
|
|
if (this.currentUser) {
|
2021-06-29 11:55:53 +02:00
|
|
|
this.$matrix
|
|
|
|
|
.getLoginPromise()
|
|
|
|
|
.then(() => {
|
|
|
|
|
self.$matrix.setCurrentRoomId(self.roomAliasOrId); // Go to this room, now or when joined.
|
|
|
|
|
const room = self.$matrix.getRoom(self.roomAliasOrId);
|
2021-01-28 22:13:08 +01:00
|
|
|
|
2021-06-29 11:55:53 +02:00
|
|
|
// Already joined?
|
2022-12-12 16:10:53 +00:00
|
|
|
if (room && room.hasMembershipState(self.currentUser.user_id, "join")) {
|
2021-06-29 11:55:53 +02:00
|
|
|
// Yes, go to room
|
|
|
|
|
self.$navigation.push(
|
|
|
|
|
{
|
|
|
|
|
name: "Chat",
|
|
|
|
|
params: { roomId: util.sanitizeRoomId(this.roomAliasOrId) },
|
|
|
|
|
},
|
|
|
|
|
-1
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log("Error logging in: ", err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
this.waitingForMembership = false;
|
|
|
|
|
this.getRoomInfo();
|
|
|
|
|
});
|
2021-01-28 22:13:08 +01:00
|
|
|
} else {
|
2021-03-12 14:57:36 +01:00
|
|
|
this.waitingForMembership = false;
|
|
|
|
|
this.getRoomInfo();
|
2021-01-28 22:13:08 +01:00
|
|
|
}
|
2021-06-29 11:55:53 +02:00
|
|
|
},
|
2021-01-28 22:13:08 +01:00
|
|
|
},
|
2022-04-21 08:06:53 +00:00
|
|
|
activeLanguage() {
|
|
|
|
|
// Null status on language change, we don't know what status we are in so we can't get the right string.
|
|
|
|
|
this.loadingMessage = null;
|
2022-12-12 16:10:53 +00:00
|
|
|
},
|
2021-01-28 22:13:08 +01:00
|
|
|
},
|
2020-11-25 10:02:24 +01:00
|
|
|
methods: {
|
2022-12-12 16:10:53 +00:00
|
|
|
removeHomeServer(roomName) {
|
2023-01-09 14:21:08 +00:00
|
|
|
let lastIndex = roomName.lastIndexOf(":");
|
|
|
|
|
if (roomName && roomName.startsWith("@")) {
|
|
|
|
|
return roomName.substring(roomName.indexOf("@") + 1, lastIndex);
|
|
|
|
|
}
|
2023-03-16 08:17:29 +00:00
|
|
|
if (roomName && roomName.startsWith("#")) {
|
|
|
|
|
return roomName.substring(roomName.indexOf("#") + 1, lastIndex);
|
|
|
|
|
}
|
|
|
|
|
return roomName ? roomName : "";
|
2022-12-12 16:10:53 +00:00
|
|
|
},
|
2021-03-12 14:57:36 +01:00
|
|
|
getRoomInfo() {
|
|
|
|
|
if (this.roomId.startsWith("#")) {
|
|
|
|
|
this.$matrix
|
|
|
|
|
.getPublicRoomInfo(this.roomId)
|
|
|
|
|
.then((room) => {
|
|
|
|
|
console.log("Found room:", room);
|
2022-12-12 16:10:53 +00:00
|
|
|
this.roomName = this.removeHomeServer(room.name);
|
2021-03-12 14:57:36 +01:00
|
|
|
this.roomAvatar = room.avatar;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log("Could not find room info", err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
this.waitingForInfo = false;
|
|
|
|
|
});
|
2022-12-12 16:10:53 +00:00
|
|
|
} else if (this.roomId.startsWith("@")) {
|
|
|
|
|
// Direct chat with user
|
2023-08-31 09:51:27 +02:00
|
|
|
this.waitingForRoomCreation = true;
|
2023-08-30 10:50:45 +02:00
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.handleJoin();
|
|
|
|
|
});
|
2021-03-12 14:57:36 +01:00
|
|
|
} else {
|
|
|
|
|
// Private room, try to get name
|
|
|
|
|
const room = this.$matrix.getRoom(this.roomId);
|
|
|
|
|
if (room) {
|
2022-12-12 16:10:53 +00:00
|
|
|
this.roomName = this.removeHomeServer(room.name || this.roomName);
|
2023-03-16 08:17:29 +00:00
|
|
|
} else {
|
|
|
|
|
this.roomName = this.removeHomeServer(this.roomAliasOrId);
|
2021-03-12 14:57:36 +01:00
|
|
|
}
|
|
|
|
|
this.waitingForInfo = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2021-01-12 20:28:23 +01:00
|
|
|
onMyMembership(room, membership, ignoredprevMembership) {
|
|
|
|
|
if (room && room.roomId == this.roomId && membership == "join") {
|
2021-01-28 22:13:08 +01:00
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$navigation.push(
|
|
|
|
|
{
|
|
|
|
|
name: "Chat",
|
|
|
|
|
params: { roomId: util.sanitizeRoomId(this.roomAliasOrId) },
|
|
|
|
|
},
|
|
|
|
|
-1
|
|
|
|
|
);
|
|
|
|
|
});
|
2021-01-12 20:28:23 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2020-12-16 15:57:44 +01:00
|
|
|
handleOpenApp() {
|
|
|
|
|
console.log("Open app..."); //TODO
|
|
|
|
|
},
|
|
|
|
|
|
2020-11-25 10:02:24 +01:00
|
|
|
handleJoin() {
|
|
|
|
|
this.loading = true;
|
2021-06-29 11:55:53 +02:00
|
|
|
this.loadingMessage = this.$t("join.status_logging_in");
|
2021-04-13 19:17:07 +02:00
|
|
|
const hasUser = this.currentUser ? true : false;
|
|
|
|
|
var setProfileData = false;
|
2021-06-29 11:55:53 +02:00
|
|
|
return this.$matrix
|
2023-04-04 14:30:50 +00:00
|
|
|
.getLoginPromise(this.$refs.interactiveAuth.registrationFlowHandler)
|
2021-01-20 09:42:13 +01:00
|
|
|
.then(
|
|
|
|
|
function (user) {
|
2021-04-13 19:17:07 +02:00
|
|
|
if (user.is_guest && !hasUser) {
|
|
|
|
|
// Newly created account, joining first room.
|
|
|
|
|
// Set avatar and display name to either the randomly chosen ones, or the
|
|
|
|
|
// ones the users has changed to.
|
|
|
|
|
setProfileData = true;
|
2021-04-13 19:57:26 +02:00
|
|
|
|
|
|
|
|
// Set display name and avatar directly on the matrix object.
|
2022-12-12 16:10:53 +00:00
|
|
|
if (this.selectedProfile.name && this.selectedProfile.name.length > 0) {
|
2021-04-13 19:57:26 +02:00
|
|
|
this.$matrix.userDisplayName = this.selectedProfile.name;
|
|
|
|
|
}
|
2021-04-13 19:17:07 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-12 16:10:53 +00:00
|
|
|
if (!setProfileData || !this.selectedProfile.name || this.selectedProfile.name.length == 0) {
|
2021-01-20 09:42:13 +01:00
|
|
|
return Promise.resolve(user);
|
|
|
|
|
} else {
|
2022-12-12 16:10:53 +00:00
|
|
|
console.log("Join: Set display name to: " + this.selectedProfile.name);
|
2023-06-07 12:55:12 +00:00
|
|
|
return this.$matrix.setUserDisplayName(this.selectedProfile.name);
|
2021-01-20 09:42:13 +01:00
|
|
|
}
|
|
|
|
|
}.bind(this)
|
|
|
|
|
)
|
|
|
|
|
.then(
|
|
|
|
|
function () {
|
2021-04-13 19:17:07 +02:00
|
|
|
if (!setProfileData || !this.selectedProfile.image) {
|
2021-03-03 15:41:15 +01:00
|
|
|
console.log("Join: No avatar change");
|
2021-01-20 09:42:13 +01:00
|
|
|
return Promise.resolve("no avatar");
|
|
|
|
|
} else {
|
2021-03-03 15:41:15 +01:00
|
|
|
console.log("Join: Updating avatar");
|
2022-12-12 16:10:53 +00:00
|
|
|
return util.setAvatar(this.$matrix, this.selectedProfile.image, function (progress) {
|
|
|
|
|
console.log("Progress: " + JSON.stringify(progress));
|
|
|
|
|
});
|
2021-01-20 09:42:13 +01:00
|
|
|
}
|
|
|
|
|
}.bind(this)
|
|
|
|
|
)
|
2022-12-12 16:10:53 +00:00
|
|
|
.then((ignoreduser) => {
|
|
|
|
|
if (this.roomId.startsWith("@")) {
|
|
|
|
|
// start direct chat with user
|
|
|
|
|
return this.$matrix.getOrCreatePrivateChat(this.roomId).then((room) => {
|
|
|
|
|
this.$matrix.setCurrentRoomId(room.roomId);
|
|
|
|
|
return room;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2021-03-03 15:41:15 +01:00
|
|
|
console.log("Join: joining room");
|
2022-08-10 18:01:58 -05:00
|
|
|
this.$analytics.event("Invitations", "Room Joined");
|
2021-06-29 11:55:53 +02:00
|
|
|
this.loadingMessage = this.$t("join.status_joining");
|
2021-01-20 09:42:13 +01:00
|
|
|
return this.$matrix.matrixClient.joinRoom(this.roomId);
|
2022-12-12 16:10:53 +00:00
|
|
|
}
|
|
|
|
|
})
|
2023-03-16 08:17:29 +00:00
|
|
|
.then((room) => {
|
2020-11-25 14:42:50 +01:00
|
|
|
this.loading = false;
|
|
|
|
|
this.loadingMessage = null;
|
2021-01-11 17:42:58 +01:00
|
|
|
this.$nextTick(() => {
|
2021-01-12 20:28:23 +01:00
|
|
|
this.$navigation.push(
|
2021-01-28 22:13:08 +01:00
|
|
|
{
|
|
|
|
|
name: "Chat",
|
2023-03-16 08:17:29 +00:00
|
|
|
params: { roomId: util.sanitizeRoomId(room.roomId) },
|
2021-01-28 22:13:08 +01:00
|
|
|
},
|
2021-01-12 20:28:23 +01:00
|
|
|
-1
|
|
|
|
|
);
|
2021-01-11 17:42:58 +01:00
|
|
|
});
|
2020-11-25 14:42:50 +01:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
// TODO - handle error
|
|
|
|
|
console.log("Failed to join room", err);
|
|
|
|
|
this.loading = false;
|
2021-07-06 10:06:30 +02:00
|
|
|
this.loadingMessage = this.$t("join.join_failed");
|
2023-10-09 15:33:41 +02:00
|
|
|
this.waitingForInfo = false;
|
|
|
|
|
this.waitingForMembership = false;
|
2020-11-25 14:42:50 +01:00
|
|
|
});
|
2020-11-25 10:02:24 +01:00
|
|
|
},
|
2021-01-18 21:40:44 +01:00
|
|
|
|
2021-02-03 22:21:53 +01:00
|
|
|
selectAvatar(value) {
|
|
|
|
|
this.selectedProfile = Object.assign({}, value); // Make a copy, so editing does not destroy data
|
2021-01-20 09:42:13 +01:00
|
|
|
},
|
|
|
|
|
|
2023-01-09 14:21:08 +00:00
|
|
|
showAvatarPicker() {
|
|
|
|
|
this.$refs.avatar.click();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handlePickedAvatar(event) {
|
|
|
|
|
util.loadAvatarFromFile(event, (image) => {
|
|
|
|
|
this.selectedProfile.image = image;
|
|
|
|
|
});
|
2021-03-03 15:41:15 +01:00
|
|
|
},
|
2020-11-25 10:02:24 +01:00
|
|
|
},
|
2021-12-19 16:04:19 +02:00
|
|
|
mounted() {
|
|
|
|
|
this.$matrix.on("Room.myMembership", this.onMyMembership);
|
|
|
|
|
this.availableAvatars = util.getDefaultAvatars();
|
2022-12-12 16:10:53 +00:00
|
|
|
this.selectAvatar(this.availableAvatars[Math.floor(Math.random() * this.availableAvatars.length)]);
|
2022-08-10 18:01:58 -05:00
|
|
|
// mounted() is called more than once, so multiple instances of this event
|
|
|
|
|
// do not necessarily indicate a user was shown the join page more than once.
|
|
|
|
|
// To analyze this data, segment users into those who have an "Invitations"
|
|
|
|
|
// action and set up conversion tracking triggered by Room Joined (once per visit).
|
|
|
|
|
this.$analytics.event("Invitations", "Join Page Shown");
|
2021-12-19 16:04:19 +02:00
|
|
|
},
|
|
|
|
|
destroyed() {
|
|
|
|
|
this.$matrix.off("Room.myMembership", this.onMyMembership);
|
2022-12-12 16:10:53 +00:00
|
|
|
},
|
2020-11-25 10:02:24 +01:00
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2022-12-12 16:10:53 +00:00
|
|
|
@import "@/assets/css/join.scss";
|
|
|
|
|
</style>
|