This commit is contained in:
syuilo 2017-11-01 13:25:09 +09:00
parent 7bf4f39c44
commit 1053083cea

View File

@ -44,6 +44,7 @@
this.posts = null; this.posts = null;
this.connection = new ChannelStream(this.id); this.connection = new ChannelStream(this.id);
this.version = VERSION; this.version = VERSION;
this.unreadCount = 0;
this.on('mount', () => { this.on('mount', () => {
document.documentElement.style.background = '#efefef'; document.documentElement.style.background = '#efefef';
@ -73,18 +74,31 @@
}); });
this.connection.on('post', this.onPost); this.connection.on('post', this.onPost);
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
}); });
this.on('unmount', () => { this.on('unmount', () => {
this.connection.off('post', this.onPost); this.connection.off('post', this.onPost);
this.connection.close(); this.connection.close();
document.removeEventListener('visibilitychange', this.onVisibilitychange);
}); });
this.onPost = post => { this.onPost = post => {
this.posts.unshift(post); this.posts.unshift(post);
this.update(); 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'
}
};
</script> </script>
</mk-channel> </mk-channel>