From 55759d99c1916000d065193f1535f65703d446c0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 1 Jul 2018 00:30:47 +0300 Subject: Unread badge --- vnext/src/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/vnext/src/index.js b/vnext/src/index.js index 1eb01eae..fda85fed 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -58,6 +58,12 @@ class App extends React.Component { try { var jsonMsg = JSON.parse(msg.data); console.log('data: ' + msg.data); + // refresh server visitor state (unread counters) + me().then(visitor => { + this.setState({ + visitor: visitor + }) + }); if (jsonMsg.service) { return; } @@ -84,7 +90,7 @@ class App extends React.Component { componentDidMount() { const { hash, uid } = this.state.visitor; this.initWS(); - if (uid === 0 && hash) { + if (hash) { me().then(visitor => this.auth(visitor)) } } @@ -111,7 +117,15 @@ class App extends React.Component {