From 1053083cea3ddcd39d607431ff02525100fa00ea Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 13:25:09 +0900 Subject: [PATCH] :v: --- src/web/app/ch/tags/channel.tag | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index 4421a4b0e..602b80bc1 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -44,6 +44,7 @@ this.posts = null; this.connection = new ChannelStream(this.id); this.version = VERSION; + this.unreadCount = 0; this.on('mount', () => { document.documentElement.style.background = '#efefef'; @@ -73,18 +74,31 @@ }); this.connection.on('post', this.onPost); + document.addEventListener('visibilitychange', this.onVisibilitychange, false); }); this.on('unmount', () => { this.connection.off('post', this.onPost); this.connection.close(); + document.removeEventListener('visibilitychange', this.onVisibilitychange); }); this.onPost = post => { this.posts.unshift(post); this.update(); + + if (document.hidden && this.SIGNIN && post.user_id !== this.I.id) { + this.unreadCount++; + document.title = `(${this.unreadCount}) ${this.channel.title} | Misskey`; + } }; + this.onVisibilitychange = () => { + if (!document.hidden) { + this.unreadCount = 0; + document.title = this.channel.title + ' | Misskey' + } + };