fix: admin/options: dialog not closing after self-signed certificate creation #931
Massimo Melina committed
Mar 9, 2025 at 11:06 UTC
c679fff98767020179cfa8b095037166ba3f7b2a
4 files changed
+12
-19
admin/src/FileForm.ts
+1
-1
@@ -449,8 +449,8 @@ export async function changeBaseUrl() {
449
async onClick() {
450
if (v !== base_url)
451
await apiCall('set_config', { values: { [CFG.base_url]: v.replace(/\/$/, '') } })
452
- resolve(v)
452
close()
453
+ resolve(v)
454
},
455
}) ),
456
)
admin/src/InternetPage.ts
+1
-1
@@ -374,7 +374,7 @@ export default function InternetPage({ setTitleSide }: PageProps) {
374
data.upnp && h(Button, {
375
size: 'small',
376
onClick() {
377
- close();
377
+ close()
378
mapPort(HIGHER_PORT).then(verifyAgain)
379
}
380
}, "Try " + HIGHER_PORT)),
admin/src/OptionsPage.ts
+7
-13
@@ -409,19 +409,13 @@ export async function suggestMakingCert() {
409
async function makeCertAndSave() {
410
if (!window.crypto.subtle)
411
return alertDialog("Retry this procedure on localhost", 'warning')
412
- const stop = waitDialog()
413
- try {
414
- await wait(50) // give time to start animation before cpu intensive task
415
- const saved = await apiCall('make_self_signed_cert', { fileName: 'self' })
416
- stop()
417
- if (loaded) // when undefined we are not in this page
418
- Object.assign(loaded, saved)
419
- setTimeout(exposedReloadStatus!, 1000) // give some time for backend to apply
420
- Object.assign(state.config, saved)
421
- close()
422
- await alertDialog("Certificate saved", 'success')
423
- }
424
- finally { stop() }
412
+ close()
413
+ const saved = await apiCall('make_self_signed_cert', { fileName: 'self' })
414
+ if (loaded) // when undefined we are not in this page
415
+ Object.assign(loaded, saved)
416
+ setTimeout(exposedReloadStatus!, 1000) // give some time for backend to apply
417
+ Object.assign(state.config, saved)
418
+ alertDialog("Certificate saved", 'success')
419
}
420
})
421
}
\ No newline at end of file
shared/dialogs.ts
+3
-4
@@ -79,11 +79,10 @@ async function back() {
79
ignorePopState = true
80
let was = history.state
81
history.back()
82
- await waitClosing
83
- return waitClosing = new Promise<void>(res => {
82
+ return waitClosing = waitClosing.then(() => new Promise<void>(res => {
83
const h = setInterval(() => was !== history.state && res() , 10)
84
setTimeout(() => clearTimeout(h), 500)
86
- })
85
+ }))
86
}
87
88
;(async () => {
@@ -192,7 +191,7 @@ export function newDialog(options: DialogOptions) {
191
const $id = Math.random()
192
const ts = performance.now()
193
const d: Dialog = Object.assign(objSameKeys(options, x => isValidElement(x) ? ref(x) : x) as typeof options, { // encapsulate elements as React will try to write, but valtio makes them readonly
195
- close, ts, $id, // object identity is not working because it's proxied (valtio). This is a possible workaroundu
194
+ close, ts, $id, // object identity is not working on dialog object because it's proxied (valtio). This is a possible workaround
195
restoreFocus: options.restoreFocus ?? ref(document.activeElement || {}),
196
})
197
let cancelOpening = false