harden code
Massimo Melina committed
Jan 30, 2026 at 22:44 UTC
edfadc2e5170731143ddc324db249bb0af261df9
1 file changed
+3
-2
frontend/src/components.ts
+3
-2
@@ -10,6 +10,7 @@ import {
10
} from 'react'
11
import _ from 'lodash'
12
import i18n from './i18n'
13
+import { alertDialog } from './dialog'
14
const { t } = i18n
15
16
export function Spinner(props: any) {
@@ -148,13 +149,13 @@ export function Btn({ icon, label, tooltip, toggled, onClick, onClickAnimation,
149
if (!onClick) return
150
if (onClickAnimation !== false)
151
setWorking(true)
151
- Promise.resolve(onClick()).finally(() => setWorking(false))
152
+ Promise.resolve().then(onClick).finally(() => setWorking(false))
153
.then(() => {
154
if (!successFeedback) return
155
setSuccess(true)
156
clearTimeout(t.current)
157
t.current = setTimeout(() => setSuccess(false), 1000)
157
- }, () => {})
158
+ }, e => alertDialog(e, 'error'))
159
},
160
...rest,
161
...asText ? { role: 'button', style: { cursor: 'pointer', ...rest.style } } : undefined,