From ff4b555c641b3da2b9408f3456ef59b53ae9b1d1 Mon Sep 17 00:00:00 2001 From: brunosimon Date: Tue, 15 Aug 2017 01:59:35 +0200 Subject: [PATCH] :sparkles: Site > Chat > Add unread count --- site/src/components/chat/script.js | 20 +++++++++++++++++++- site/src/components/chat/template.html | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/site/src/components/chat/script.js b/site/src/components/chat/script.js index b1e914e..1f319d8 100644 --- a/site/src/components/chat/script.js +++ b/site/src/components/chat/script.js @@ -7,7 +7,8 @@ export default return { userName: '', messageText: '', - open: false + open: false, + unreadCount: 0 } }, @@ -33,6 +34,11 @@ export default messages() { + if(!this.atBottom || !this.open) + { + this.unreadCount++ + } + window.requestAnimationFrame(() => { if(this.atBottom) @@ -59,6 +65,12 @@ export default onHeaderClick() { this.open = !this.open + + // Reset unread count + if(this.open) + { + this.unreadCount = 0 + } }, onUserNameChange() @@ -91,6 +103,12 @@ export default onMessagesScroll() { this.atBottom = this.$messages.scrollTop + this.$messages.offsetHeight >= this.$innerMessages.offsetHeight - 15 + + // Reset unread count + if(this.atBottom) + { + this.unreadCount = 0 + } } } } \ No newline at end of file diff --git a/site/src/components/chat/template.html b/site/src/components/chat/template.html index b96085d..3a9d456 100644 --- a/site/src/components/chat/template.html +++ b/site/src/components/chat/template.html @@ -1,6 +1,6 @@
- Discussions + Discussions ({{ unreadCount }})