diff options
author | Renard | 2019-09-30 14:42:12 -0300 |
---|---|---|
committer | Renard | 2019-09-30 14:42:12 -0300 |
commit | 00177c2fb08c41aac4ca645c5658f5ad83598d59 (patch) | |
tree | e75013128ecca6b70f817942f8ed2228486b290d /src | |
parent | fb7f4b112f623716f9b2c4a36939f0e3b65f1403 (diff) | |
download | bai-client-00177c2fb08c41aac4ca645c5658f5ad83598d59.tar.gz bai-client-00177c2fb08c41aac4ca645c5658f5ad83598d59.tar.xz bai-client-00177c2fb08c41aac4ca645c5658f5ad83598d59.zip |
Notificación de posts nuevo en thread y contador
Diffstat (limited to 'src')
-rw-r--r-- | src/Thread.js | 15 |
1 files changed, 13 insertions, 2 deletions
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 ( <Container className={nightMode ? "thread inverted" : "thread"}> |