fix: account.redirect without slash caused many redirects
Massimo Melina committed
Mar 23, 2023 at 21:58 UTC
7c5de336c63b11f2bb9cb52dd0728e61ad1cbefc
1 file changed
+10
-8
frontend/src/useFetchList.ts
+10
-8
@@ -75,31 +75,33 @@ export default function useFetchList() {
75
return
76
case 'msg':
77
state.loginRequired = false
78
- data.forEach(async (entry: any) => {
78
+ for (const entry of data) {
79
const { error } = entry
80
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)
81
state.messageOnly = t('upload_starting', "Your download should now start")
82
window.location.reload() // reload will start the download, because now we got authenticated
83
- return
83
+ continue
84
}
85
if (error) {
86
state.stopSearch?.()
87
state.error = (ERRORS as any)[error] || String(error)
88
if (error === 401 && snap.username)
89
- await alertDialog(t('wrong_account', { u: snap.username }, "Account {u} has no access, try another"), 'warning')
89
+ alertDialog(t('wrong_account', { u: snap.username }, "Account {u} has no access, try another"), 'warning')
90
state.loginRequired = error === 401
91
lastReq.current = null
92
- return
92
+ continue
93
}
94
if (!desiredPath.endsWith('/')) // now we know it was a folder for sure
95
return navigate(desiredPath + '/')
96
- if (entry.props)
97
- return Object.assign(state, _.pick(entry.props, ['can_upload', 'can_delete']))
96
+ if (entry.props) {
97
+ Object.assign(state, _.pick(entry.props, ['can_upload', 'can_delete']))
98
+ continue
99
+ }
100
state.can_upload ??= false
101
state.can_delete ??= false
102
if (entry.add)
101
- return buffer.push(entry.add)
102
- })
103
+ buffer.push(entry.add)
104
+ }
105
if (src?.readyState === src?.CLOSED)
106
return state.stopSearch?.()
107
}