prevent Reload UI button/link from reloading the page when it's not yet ready

This commit is contained in:
AUTOMATIC 2023-05-09 11:42:47 +03:00
parent eb95809501
commit ad6ec02261
2 changed files with 12 additions and 1 deletions

View File

@ -395,7 +395,16 @@ function update_token_counter(button_id) {
function restart_reload(){
document.body.innerHTML='<h1 style="font-family:monospace;margin-top:20%;color:lightgray;text-align:center;">Reloading...</h1>';
setTimeout(function(){location.reload()},2000)
var requestPing = function(){
requestGet("./internal/ping", {}, function(data){
location.reload();
}, function(){
setTimeout(requestPing, 500);
})
}
setTimeout(requestPing, 2000);
return []
}

View File

@ -1958,3 +1958,5 @@ def setup_ui_api(app):
return [QuicksettingsHint(name=k, label=v.label) for k, v in opts.data_labels.items()]
app.add_api_route("/internal/quicksettings-hint", quicksettings_hint, methods=["GET"], response_model=List[QuicksettingsHint])
app.add_api_route("/internal/ping", lambda: {}, methods=["GET"])