diff options
Diffstat (limited to 'vnext')
-rw-r--r-- | vnext/src/App.js | 11 | ||||
-rw-r--r-- | vnext/src/api/index.js | 2 | ||||
-rw-r--r-- | vnext/src/index.js | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/vnext/src/App.js b/vnext/src/App.js index 9612bd83..befbb0ad 100644 --- a/vnext/src/App.js +++ b/vnext/src/App.js @@ -40,12 +40,17 @@ export default function App({ footer }) { let retpath = params['retpath'] || `${window.location.protocol}//${window.location.host}${window.location.pathname}` window.history.replaceState({}, document.title, retpath) }*/ - }, []) + }, [updateStatus]) let updateStatus = useCallback(() => { // refresh server visitor state (unread counters) - me().then(visitor => { - setVisitor(visitor) + me().then(response => { + setVisitor((prevState) => { + if (prevState !== response.data) { + return response.data + } + return prevState + }) }).catch(console.error) }, [setVisitor]) diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index 7d878864..73f6c727 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -72,7 +72,7 @@ const client = axios.create({ baseURL: '' }) /** * fetch my info - * @returns {Promise<SecureUser, Error>} me object + * @returns {Promise<import('axios').AxiosResponse, Error>} me object */ export function me() { return client.get('/api/me') diff --git a/vnext/src/index.js b/vnext/src/index.js index aa39e810..81b8e93d 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -30,7 +30,7 @@ function ready(fn) { ready(async () => { let visitor try { - visitor = await me() + visitor = (await me()).data } catch (e) { visitor = undefined } |