Add notification count
Add count to tab title and room list. Issue #49.
This commit is contained in:
parent
9c9619fe1c
commit
ee3dd935be
4 changed files with 56 additions and 9 deletions
18
src/App.vue
18
src/App.vue
|
|
@ -25,20 +25,26 @@ export default {
|
||||||
currentUser() {
|
currentUser() {
|
||||||
return this.$store.state.auth.user;
|
return this.$store.state.auth.user;
|
||||||
},
|
},
|
||||||
},
|
title() {
|
||||||
watch: {
|
|
||||||
'$route' (to, ignoredFrom) {
|
|
||||||
var title = "Keanu Weblite";
|
var title = "Keanu Weblite";
|
||||||
if (to.meta.title) {
|
if (this.$matrix.notificationCount > 0) {
|
||||||
title += " - " + to.meta.title;
|
title += " [" + this.$matrix.notificationCount + "]";
|
||||||
}
|
}
|
||||||
if (to.meta.includeRoom) {
|
if (this.$route.meta.title) {
|
||||||
|
title += " - " + this.$route.meta.title;
|
||||||
|
}
|
||||||
|
if (this.$route.meta.includeRoom) {
|
||||||
if (this.$matrix.currentRoom) {
|
if (this.$matrix.currentRoom) {
|
||||||
title += " - " + (this.$matrix.currentRoom.summary.info.title || this.$matrix.currentRoom.roomId);
|
title += " - " + (this.$matrix.currentRoom.summary.info.title || this.$matrix.currentRoom.roomId);
|
||||||
} else if (this.$matrix.currentRoomId) {
|
} else if (this.$matrix.currentRoomId) {
|
||||||
title += " - " + (this.$matrix.currentRoomId);
|
title += " - " + (this.$matrix.currentRoomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
title(title) {
|
||||||
document.title = title;
|
document.title = title;
|
||||||
},
|
},
|
||||||
currentUser: {
|
currentUser: {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ $admin-fg: white;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid #e0e0e0;
|
border: 1px solid #e0e0e0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
max-height: 60%;
|
||||||
|
overflow-y: auto;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
.v-subheader {
|
.v-subheader {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
@ -45,6 +47,22 @@ $admin-fg: white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.room-list-notification-count {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
left: 40px;
|
||||||
|
color: white;
|
||||||
|
background-color: black;
|
||||||
|
font-size: 10px;
|
||||||
|
min-width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 2px solid white;
|
||||||
|
text-align: center;
|
||||||
|
padding-left: 4px;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.chat-root {
|
.chat-root {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@
|
||||||
<v-subheader>ROOMS</v-subheader>
|
<v-subheader>ROOMS</v-subheader>
|
||||||
<v-list-item-group v-model="currentRoomId" color="primary">
|
<v-list-item-group v-model="currentRoomId" color="primary">
|
||||||
<v-list-item v-for="room in $matrix.rooms" :key="room.roomId" :value="room.roomId">
|
<v-list-item v-for="room in $matrix.rooms" :key="room.roomId" :value="room.roomId">
|
||||||
<v-list-item-avatar color="#e0e0e0">
|
<v-list-item-avatar size="40" color="#e0e0e0">
|
||||||
<v-img :src="room.avatar" />
|
<v-img :src="room.avatar" />
|
||||||
</v-list-item-avatar>
|
</v-list-item-avatar>
|
||||||
|
<div class="room-list-notification-count">{{ notificationCount(room) }}</div>
|
||||||
<v-list-item-content>
|
<v-list-item-content>
|
||||||
<v-list-item-title>{{ room.summary.info.title }}</v-list-item-title>
|
<v-list-item-title>{{ room.summary.info.title }}</v-list-item-title>
|
||||||
<v-list-item-subtitle>{{ room.topic }}</v-list-item-subtitle>
|
<v-list-item-subtitle>{{ room.topic }}</v-list-item-subtitle>
|
||||||
|
|
@ -22,9 +23,15 @@ export default {
|
||||||
name: "RoomList",
|
name: "RoomList",
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
currentRoomId: -1,
|
currentRoomId: null,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
notificationCount(room) {
|
||||||
|
return room.getUnreadNotificationCount('total') || 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
currentRoomId() {
|
currentRoomId() {
|
||||||
this.$emit("close");
|
this.$emit("close");
|
||||||
|
|
@ -33,3 +40,7 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import "@/assets/css/chat.scss";
|
||||||
|
</style>
|
||||||
|
|
@ -28,6 +28,7 @@ export default {
|
||||||
userDisplayName: null,
|
userDisplayName: null,
|
||||||
userAvatar: null,
|
userAvatar: null,
|
||||||
currentRoom: null,
|
currentRoom: null,
|
||||||
|
notificationCount: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
@ -59,7 +60,7 @@ export default {
|
||||||
handler(roomId) {
|
handler(roomId) {
|
||||||
this.currentRoom = this.getRoom(roomId);
|
this.currentRoom = this.getRoom(roomId);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -274,11 +275,13 @@ export default {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this.updateNotificationCount();
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoom(ignoredroom) {
|
onRoom(ignoredroom) {
|
||||||
console.log("Got room: " + ignoredroom);
|
console.log("Got room: " + ignoredroom);
|
||||||
this.reloadRooms();
|
this.reloadRooms();
|
||||||
|
this.updateNotificationCount();
|
||||||
},
|
},
|
||||||
|
|
||||||
onSessionLoggedOut() {
|
onSessionLoggedOut() {
|
||||||
|
|
@ -411,7 +414,16 @@ export default {
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
return Promise.reject("Failed to find room: " + err);
|
return Promise.reject("Failed to find room: " + err);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateNotificationCount() {
|
||||||
|
var count = 0;
|
||||||
|
this.rooms.forEach(room => {
|
||||||
|
count += room.getUnreadNotificationCount('total') || 0;
|
||||||
|
});
|
||||||
|
this.notificationCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue