aboutsummaryrefslogtreecommitdiff
path: root/vnext
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-02-18 23:06:13 +0300
committerGravatar Vitaly Takmazov2024-02-18 23:19:18 +0300
commit67f6f99665c0dfa3cbb0197d78e0e929b3d1ddee (patch)
tree6113cde5a6b02524dae8006117f5cbd909f9d59f /vnext
parentb9bceb8e977de93dcdacec31c3f2de3af73760a7 (diff)
vnext: fix login
Diffstat (limited to 'vnext')
-rw-r--r--vnext/src/App.js11
-rw-r--r--vnext/src/api/index.js2
-rw-r--r--vnext/src/index.js2
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
}