fix: avoid getting the same error dialog twice - reproduce by clicking on a protected folder and providing a different account
fix: avoid getting the same error dialog twice - reproduce by clicking on a protected folder and providing a different account
Massimo Melina committed
Apr 6, 2025 at 10:53 UTC
5a14f72446db0ca66d5b59f0429160a3cbb25941
3 files changed
+5
-2
frontend/src/dialog.ts
+3
@@ -115,7 +115,10 @@ export async function formDialog({ ...rest }: DialogOptions): Promise<any> {
115
116
export type AlertType = 'error' | 'warning' | 'info'
117
118
+let lastMsg: any
119
export function alertDialog(msg: ReactElement | string | Error, type:AlertType='info', title='') {
120
+ if (msg === lastMsg) return
121
+ lastMsg = msg
122
if (msg instanceof Error)
123
type = 'error'
124
const ret = pendingPromise()
frontend/src/fileMenu.ts
+1
-1
@@ -178,7 +178,7 @@ async function rename(entry: DirEntry) {
178
await apiCall('rename', { uri, dest }, { modal: working })
179
const MSG = t`Operation successful`
180
if (uri === location.pathname) //current folder
181
- return alertDialog(MSG).then(() =>
181
+ return alertDialog(MSG)?.then(() =>
182
getHFS().navigate(uri + '../' + pathEncode(dest) + '/') )
183
// update state instead of re-getting the list
184
const newN = n.replace(/(.*?)[^/]+$/, (_,before) => before + dest)
frontend/src/uploadQueue.ts
+1
-1
@@ -226,7 +226,7 @@ export async function startUpload(toUpload: ToUpload, to: string, resume=0) {
226
if (uploadState.errors.push(toUpload)) return
227
const msg = t('failed_upload', toUpload, "Couldn't upload {name}") + prefix(': ', specifier)
228
closeLastDialog?.()
229
- closeLastDialog = alertDialog(msg, 'error').close
229
+ closeLastDialog = alertDialog(msg, 'error')?.close
230
}
231
232
function next() {