From 00177c2fb08c41aac4ca645c5658f5ad83598d59 Mon Sep 17 00:00:00 2001 From: Renard Date: Mon, 30 Sep 2019 14:42:12 -0300 Subject: Notificación de posts nuevo en thread y contador --- src/Thread.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Thread.js') diff --git a/src/Thread.js b/src/Thread.js index 39d8382..c79e7e0 100644 --- a/src/Thread.js +++ b/src/Thread.js @@ -27,6 +27,10 @@ class Thread extends Component { this.lastTime = 0; this.refreshCooldown = 15; this.cooldownCounter = 0; + this.newPostCounter = 0; + this.notificationSound = new Audio( + "https://bienvenidoainternet.org/msn.ogg" + ); } componentDidMount() { @@ -81,13 +85,15 @@ class Thread extends Component { if (resource.state === "success") { if (resource.posts.length > 0) { const newPosts = this.state.thread.posts.concat(resource.posts); + this.refreshCooldown = 15; + this.newPostCounter += resource.posts.length; + this.notificationSound.play(); this.setState(({ thread }) => ({ thread: { ...thread, posts: newPosts } })); - this.refreshCooldown = 15; } else { this.refreshCooldown += 15; if (this.refreshCooldown > 60) { @@ -134,7 +140,12 @@ class Thread extends Component { const currentBoard = boardList.find(board => { return board.dir === dir; }); - document.title = subject + " - " + currentBoard.name + "@B.a.I"; + + let npCounter = ""; + if (this.newPostCounter !== 0) { + npCounter = "(" + this.newPostCounter + ") "; + } + document.title = `${npCounter}${subject} - ${currentBoard.name}@BaI`; return ( -- cgit v1.2.1-18-gbd029