fix: admin/options: certificate errors may not be refreshed after save
Massimo Melina committed
May 6, 2023 at 15:53 UTC
7b59f551ff9ff98bf15d9731febf84015859dde4
1 file changed
+4
-2
admin/src/OptionsPage.ts
+4
-2
@@ -183,7 +183,8 @@ export default function OptionsPage() {
183
return alertDialog("You cannot randomize this port unless you have a working fixed port for " + otherProtocol, 'warning')
184
if (newPort > 0 && !await confirmDialog("You are changing the port and you may be disconnected"))
185
return
186
- if (onHttps && ('cert' in changes || 'private_key' in changes) && !await confirmDialog("You may disrupt https service, kicking you out"))
186
+ const certChange = 'cert' in changes || 'private_key' in changes
187
+ if (onHttps && certChange && !await confirmDialog("You may disrupt https service, kicking you out"))
188
return
189
await apiCall('set_config', { values: changes })
190
if (newPort !== undefined) {
@@ -192,7 +193,8 @@ export default function OptionsPage() {
193
return window.location.href = newPort <= 0 ? (onHttps ? 'http:' : 'https:') + '//' + loc.hostname + ':' + otherPort + loc.pathname
194
: loc.protocol + '//' + loc.hostname + ':' + newPort + loc.pathname
195
}
195
- setTimeout(reloadStatus, 'port' in changes || 'https_port' in changes ? 1000 : 0) // give some time to consider new ports
196
+ const portChange = 'port' in changes || 'https_port' in changes
197
+ setTimeout(reloadStatus, portChange || certChange ? 1000 : 0) // give some time to apply news
198
Object.assign(loaded!, changes) // since changes are recalculated subscribing state.config, but it depends on 'loaded' to (which cannot be subscribed), be sure to update loaded first
199
recalculateChanges()
200
toast("Changes applied", 'success')