fix: logout was not refreshing screen to reflect new state

Massimo Melina committed Mar 28, 2023 at 00:05 UTC 3d4ff7de564edb1d393e1847db8df3db5f0014a2
1 file changed +4 -3
frontend/src/login.ts
+4 -3
@@ -7,6 +7,7 @@ import { getPrefixUrl, hIcon, srpSequence, working } from './misc'
7 import { useNavigate } from 'react-router-dom'
8 import { createElement as h, Fragment, useEffect, useRef } from 'react'
9 import { t, useI18N } from './i18n'
10 +import { reloadList } from './useFetchList'
11
12 async function login(username:string, password:string) {
13 const stopWorking = working()
@@ -40,10 +41,10 @@ function sessionRefresher(response: any) {
41
42 export function logout(){
43 return apiCall('logout').catch(res => {
43 - if (res.code === 401) // we expect 401
44 - state.username = ''
45 - else
44 + if (res.code !== 401) // we expect 401
45 throw res
46 + state.username = ''
47 + reloadList()
48 })
49 }
50