2020-11-09 10:26:56 +01:00
|
|
|
<template>
|
2021-02-01 22:10:48 +01:00
|
|
|
<v-list dense class="room-list">
|
2021-06-24 13:01:15 +02:00
|
|
|
<div v-if="showInvites && $matrix.invites.length > 0" class="h4">
|
|
|
|
|
{{ invitesTitle }}
|
|
|
|
|
</div>
|
|
|
|
|
<v-list-item-group
|
|
|
|
|
v-if="showInvites"
|
|
|
|
|
v-model="currentRoomId"
|
|
|
|
|
color="primary"
|
|
|
|
|
>
|
2021-04-14 12:37:42 +02:00
|
|
|
<v-slide-y-transition group>
|
2021-06-24 13:01:15 +02:00
|
|
|
<v-list-item
|
|
|
|
|
:disabled="roomsProcessing[room.roomId]"
|
|
|
|
|
v-for="room in $matrix.invites"
|
|
|
|
|
:key="room.roomId"
|
|
|
|
|
:value="room.roomId"
|
|
|
|
|
>
|
|
|
|
|
<v-list-item-avatar size="40" color="#e0e0e0">
|
|
|
|
|
<v-img :src="room.avatar" />
|
|
|
|
|
</v-list-item-avatar>
|
|
|
|
|
<v-list-item-content>
|
|
|
|
|
<v-list-item-title>{{
|
|
|
|
|
room.name || room.summary.info.title
|
|
|
|
|
}}</v-list-item-title>
|
|
|
|
|
<v-list-item-subtitle>{{ room.topic }}</v-list-item-subtitle>
|
|
|
|
|
</v-list-item-content>
|
|
|
|
|
<v-list-item-action>
|
|
|
|
|
<v-btn @click.stop="acceptInvitation(room)" icon
|
|
|
|
|
><v-icon>check_circle</v-icon></v-btn
|
|
|
|
|
>
|
|
|
|
|
<v-btn @click.stop="rejectInvitation(room)" icon
|
|
|
|
|
><v-icon>cancel</v-icon></v-btn
|
|
|
|
|
>
|
|
|
|
|
</v-list-item-action>
|
|
|
|
|
</v-list-item>
|
2021-04-14 12:37:42 +02:00
|
|
|
</v-slide-y-transition>
|
|
|
|
|
</v-list-item-group>
|
2021-06-24 13:01:15 +02:00
|
|
|
<div class="h4">{{ title }}</div>
|
2020-11-09 15:08:36 +01:00
|
|
|
<v-list-item-group v-model="currentRoomId" color="primary">
|
2021-05-27 12:17:08 +02:00
|
|
|
<v-list-item v-if="showCreate" @click.stop="$emit('newroom')">
|
|
|
|
|
<v-list-item-content>
|
2021-06-24 13:01:15 +02:00
|
|
|
<v-list-item-title class="new-room">{{
|
|
|
|
|
$t("menu.new_room")
|
|
|
|
|
}}</v-list-item-title>
|
2021-05-27 12:17:08 +02:00
|
|
|
</v-list-item-content>
|
|
|
|
|
</v-list-item>
|
|
|
|
|
|
2021-06-24 13:01:15 +02:00
|
|
|
<v-list-item
|
|
|
|
|
v-for="room in $matrix.joinedRooms"
|
|
|
|
|
:key="room.roomId"
|
|
|
|
|
:value="room.roomId"
|
2021-06-29 11:55:53 +02:00
|
|
|
style="position: relative"
|
2021-06-24 13:01:15 +02:00
|
|
|
>
|
2021-02-17 10:43:42 +01:00
|
|
|
<v-list-item-avatar size="40" color="#e0e0e0">
|
2020-11-11 17:35:14 +01:00
|
|
|
<v-img :src="room.avatar" />
|
|
|
|
|
</v-list-item-avatar>
|
2021-06-24 13:01:15 +02:00
|
|
|
<div class="room-list-notification-count">
|
|
|
|
|
{{ notificationCount(room) }}
|
|
|
|
|
</div>
|
2020-11-09 10:26:56 +01:00
|
|
|
<v-list-item-content>
|
2020-11-09 15:55:17 +01:00
|
|
|
<v-list-item-title>{{ room.summary.info.title }}</v-list-item-title>
|
|
|
|
|
<v-list-item-subtitle>{{ room.topic }}</v-list-item-subtitle>
|
2020-11-09 10:26:56 +01:00
|
|
|
</v-list-item-content>
|
|
|
|
|
</v-list-item>
|
|
|
|
|
</v-list-item-group>
|
|
|
|
|
</v-list>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-02-01 16:04:12 +01:00
|
|
|
import util from "../plugins/utils";
|
2021-06-24 13:01:15 +02:00
|
|
|
import Vue from "vue";
|
2021-02-01 16:04:12 +01:00
|
|
|
|
2020-11-09 10:26:56 +01:00
|
|
|
export default {
|
|
|
|
|
name: "RoomList",
|
|
|
|
|
|
2021-03-11 13:55:10 +01:00
|
|
|
props: {
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
2021-06-24 13:01:15 +02:00
|
|
|
default: "Rooms",
|
2021-04-14 12:37:42 +02:00
|
|
|
},
|
|
|
|
|
invitesTitle: {
|
|
|
|
|
type: String,
|
2021-06-24 13:01:15 +02:00
|
|
|
default: "Invites",
|
2021-04-14 12:37:42 +02:00
|
|
|
},
|
|
|
|
|
showInvites: {
|
|
|
|
|
type: Boolean,
|
2021-06-24 13:01:15 +02:00
|
|
|
default: false,
|
2021-05-27 12:17:08 +02:00
|
|
|
},
|
|
|
|
|
showCreate: {
|
|
|
|
|
type: Boolean,
|
2021-06-24 13:01:15 +02:00
|
|
|
default: false,
|
|
|
|
|
},
|
2021-03-11 13:55:10 +01:00
|
|
|
},
|
|
|
|
|
|
2020-11-09 10:26:56 +01:00
|
|
|
data: () => ({
|
2021-02-17 10:43:42 +01:00
|
|
|
currentRoomId: null,
|
2021-04-14 12:37:42 +02:00
|
|
|
/** A list of rooms currently processing some operation, like "join" or "reject" */
|
|
|
|
|
roomsProcessing: {},
|
2020-11-09 10:26:56 +01:00
|
|
|
}),
|
|
|
|
|
|
2021-02-17 10:43:42 +01:00
|
|
|
methods: {
|
|
|
|
|
notificationCount(room) {
|
2021-06-24 13:01:15 +02:00
|
|
|
return room.getUnreadNotificationCount("total") || 0;
|
2021-04-14 12:37:42 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
acceptInvitation(room) {
|
|
|
|
|
Vue.set(this.roomsProcessing, room.roomId, true);
|
2021-06-24 13:01:15 +02:00
|
|
|
this.$matrix.matrixClient
|
|
|
|
|
.joinRoom(room.roomId)
|
2021-04-14 12:37:42 +02:00
|
|
|
.then((ignoredRoom) => {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$navigation.push(
|
|
|
|
|
{
|
|
|
|
|
name: "Chat",
|
2021-06-24 13:01:15 +02:00
|
|
|
params: {
|
|
|
|
|
roomId: util.sanitizeRoomId(
|
|
|
|
|
room.getCanonicalAlias() || room.roomId
|
|
|
|
|
),
|
|
|
|
|
},
|
2021-04-14 12:37:42 +02:00
|
|
|
},
|
|
|
|
|
-1
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.error("Failed to accept invite: ", err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
Vue.delete(this.roomsProcessing, room.roomId);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
rejectInvitation(room) {
|
|
|
|
|
Vue.set(this.roomsProcessing, room.roomId, true);
|
2021-06-24 13:01:15 +02:00
|
|
|
this.$matrix
|
|
|
|
|
.leaveRoom(room.roomId)
|
2021-04-14 12:37:42 +02:00
|
|
|
.catch((err) => {
|
|
|
|
|
console.error("Failed to reject invite: ", err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
Vue.delete(this.roomsProcessing, room.roomId);
|
|
|
|
|
});
|
|
|
|
|
},
|
2021-02-17 10:43:42 +01:00
|
|
|
},
|
|
|
|
|
|
2020-11-09 10:26:56 +01:00
|
|
|
watch: {
|
2020-11-09 15:08:36 +01:00
|
|
|
currentRoomId() {
|
2021-05-27 13:39:38 +02:00
|
|
|
if (this.currentRoomId == null) {
|
|
|
|
|
// Ignore, this is caused by "new room" etc.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-11-19 17:11:11 +01:00
|
|
|
this.$emit("close");
|
2021-06-24 13:01:15 +02:00
|
|
|
this.$navigation.push(
|
|
|
|
|
{
|
|
|
|
|
name: "Chat",
|
|
|
|
|
params: { roomId: util.sanitizeRoomId(this.currentRoomId) },
|
|
|
|
|
},
|
|
|
|
|
-1
|
|
|
|
|
);
|
2020-11-09 10:26:56 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
2021-02-17 10:43:42 +01:00
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "@/assets/css/chat.scss";
|
2021-04-14 12:37:42 +02:00
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
/** Align action buttons side to side */
|
|
|
|
|
.v-list-item__action--stack {
|
|
|
|
|
flex-direction: row !important;
|
|
|
|
|
}
|
2021-02-17 10:43:42 +01:00
|
|
|
</style>
|