From adef6007788557b4a5847de67049c14f32975d1b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 20 Jun 2018 01:00:22 +0300 Subject: fix initial load with hash --- vnext/src/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vnext/src/index.js b/vnext/src/index.js index e2090b78..a5bfa1c5 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -17,7 +17,10 @@ class App extends React.Component { super(props); this.auth = this.auth.bind(this); this.state = { - visitor: { uid: 0 }, + visitor: { + uid: window.localStorage.uid || 0, + hash: window.localStorage.hash || '' + }, headerClassName: '' }; this.dHeight = 0; @@ -58,7 +61,7 @@ class App extends React.Component { } this.wScrollBefore = this.wScrollCurrent; })); - this.auth(window.localStorage.hash || '') + this.auth(this.state.visitor.hash) } throttle(delay, fn) { var last, deferTimer; @@ -201,8 +204,9 @@ class App extends React.Component { return response.json() }) .then(users => { - let visitor = users[0] - visitor.hash = data + let visitor = users[0]; + visitor.hash = data; + window.localStorage.uid = visitor.uid; this.setState({ visitor: visitor }) -- cgit v1.2.3