avoid flickering on spinner during login
Massimo Melina committed
Jan 9, 2022 at 12:54 UTC
3d4c5aef46c14674cf104b4dead89508991c9a20
1 file changed
+3
frontend/src/login.ts
+3
@@ -2,12 +2,14 @@ import { apiCall, ApiError } from './api'
2
import { state } from './state'
3
import { alertDialog } from './dialog'
4
import { SRPClientSession, SRPParameters, SRPRoutines } from 'tssrp6a'
5
+import { working } from './misc'
6
7
let refresher: NodeJS.Timeout
8
9
export async function login(user:string, password:string) {
10
if (refresher)
11
clearInterval(refresher)
12
+ const stopWorking = working()
13
try {
14
/* simple login without encryption. Here commented just for example. Please use SRP version.
15
const res = await apiCall('login', { user, password })
@@ -39,6 +41,7 @@ export async function login(user:string, password:string) {
41
err = 'Invalid credentials'
42
await alertDialog(err as Error, 'error')
43
}
44
+ finally { stopWorking() }
45
}
46
apiCall('refresh_session').then(sessionRefresher, ()=>{})
47