✨ Site > Chat > Add unread count
This commit is contained in:
@@ -7,7 +7,8 @@ export default
|
|||||||
return {
|
return {
|
||||||
userName: '',
|
userName: '',
|
||||||
messageText: '',
|
messageText: '',
|
||||||
open: false
|
open: false,
|
||||||
|
unreadCount: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -33,6 +34,11 @@ export default
|
|||||||
|
|
||||||
messages()
|
messages()
|
||||||
{
|
{
|
||||||
|
if(!this.atBottom || !this.open)
|
||||||
|
{
|
||||||
|
this.unreadCount++
|
||||||
|
}
|
||||||
|
|
||||||
window.requestAnimationFrame(() =>
|
window.requestAnimationFrame(() =>
|
||||||
{
|
{
|
||||||
if(this.atBottom)
|
if(this.atBottom)
|
||||||
@@ -59,6 +65,12 @@ export default
|
|||||||
onHeaderClick()
|
onHeaderClick()
|
||||||
{
|
{
|
||||||
this.open = !this.open
|
this.open = !this.open
|
||||||
|
|
||||||
|
// Reset unread count
|
||||||
|
if(this.open)
|
||||||
|
{
|
||||||
|
this.unreadCount = 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onUserNameChange()
|
onUserNameChange()
|
||||||
@@ -91,6 +103,12 @@ export default
|
|||||||
onMessagesScroll()
|
onMessagesScroll()
|
||||||
{
|
{
|
||||||
this.atBottom = this.$messages.scrollTop + this.$messages.offsetHeight >= this.$innerMessages.offsetHeight - 15
|
this.atBottom = this.$messages.scrollTop + this.$messages.offsetHeight >= this.$innerMessages.offsetHeight - 15
|
||||||
|
|
||||||
|
// Reset unread count
|
||||||
|
if(this.atBottom)
|
||||||
|
{
|
||||||
|
this.unreadCount = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="chat">
|
<div class="chat">
|
||||||
<header class="header" @click="onHeaderClick">
|
<header class="header" @click="onHeaderClick">
|
||||||
Discussions
|
Discussions ({{ unreadCount }})
|
||||||
</header>
|
</header>
|
||||||
<div class="content" v-show="open">
|
<div class="content" v-show="open">
|
||||||
<div class="messages" @scroll="onMessagesScroll">
|
<div class="messages" @scroll="onMessagesScroll">
|
||||||
|
|||||||
Reference in New Issue
Block a user