adapt frontend to new api
Massimo Melina committed
Aug 10, 2022 at 15:02 UTC
036aebd4cf861e20516914e61e1b03a7dd332f84
1 file changed
+16
-15
frontend/src/useFetchList.ts
+16
-15
@@ -53,23 +53,24 @@ export default function useFetchList() {
53
state.loading = false
54
return
55
case 'msg':
56
+ data.forEach((data: any) => {
57
+ if (data.add)
58
+ return buffer.push(data.add)
59
+ const { error } = data
60
+ if (error === 405) { // "method not allowed" happens when we try to directly access an unauthorized file, and we get a login prompt, and then file_list the file (because we didn't know it was file or folder)
61
+ state.messageOnly = "Your download should now start"
62
+ window.location.reload() // reload will start the download, because now we got authenticated
63
+ return
64
+ }
65
+ if (error) {
66
+ state.stopSearch?.()
67
+ state.error = (ERRORS as any)[error] || String(error)
68
+ state.loginRequired = error === 401
69
+ return
70
+ }
71
+ })
72
if (src?.readyState === src?.CLOSED)
73
return state.stopSearch?.()
58
- if (!data) return
59
- if (data.add)
60
- return buffer.push(data.add)
61
- const { error } = data
62
- if (error === 405) { // "method not allowed" happens when we try to directly access an unauthorized file, and we get a login prompt, and then file_list the file (because we didn't know it was file or folder)
63
- state.messageOnly = "Your download should now start"
64
- window.location.reload() // reload will start the download, because now we got authenticated
65
- return
66
- }
67
- if (error) {
68
- state.stopSearch?.()
69
- state.error = (ERRORS as any)[error] || String(error)
70
- state.loginRequired = error === 401
71
- return
72
- }
74
}
75
})
76
state.stopSearch = ()=>{