From 67f6f99665c0dfa3cbb0197d78e0e929b3d1ddee Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 18 Feb 2024 23:06:13 +0300 Subject: vnext: fix login --- vnext/src/App.js | 11 ++++++++--- vnext/src/api/index.js | 2 +- vnext/src/index.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'vnext') 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} me object + * @returns {Promise} 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 } -- cgit v1.2.3