auto-start fix
This commit is contained in:
parent
e1f068f97f
commit
f9804ecb00
@ -390,9 +390,11 @@ def api_soundboard_load():
|
|||||||
sb = load_soundboard_config(filename,
|
sb = load_soundboard_config(filename,
|
||||||
current_app.config['SOUNDBOARD_CONFIG_DIR'],
|
current_app.config['SOUNDBOARD_CONFIG_DIR'],
|
||||||
current_app.config['SOUNDS_DIR'])
|
current_app.config['SOUNDS_DIR'])
|
||||||
state.current_soundboard = sb
|
# Wenn das gleiche Theme erneut geladen wird, Auto-Random nicht stoppen
|
||||||
# Stoppe ggf. laufende Auto-Randoms beim Laden neuer Themen
|
same_theme = state.current_soundboard and state.current_soundboard.get('filename') == filename
|
||||||
|
if not same_theme:
|
||||||
_stop_auto_random_internal()
|
_stop_auto_random_internal()
|
||||||
|
state.current_soundboard = sb
|
||||||
logger.info(f"Soundboard geladen: {filename}")
|
logger.info(f"Soundboard geladen: {filename}")
|
||||||
return jsonify({"success": True, "soundboard": sb})
|
return jsonify({"success": True, "soundboard": sb})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -453,6 +455,13 @@ def api_soundboard_auto_stop():
|
|||||||
return jsonify({"success": True, "message": "Auto-Random gestoppt", "was_running": stopped})
|
return jsonify({"success": True, "message": "Auto-Random gestoppt", "was_running": stopped})
|
||||||
|
|
||||||
|
|
||||||
|
@api_bp.route('/soundboard/current', methods=['GET'])
|
||||||
|
def api_soundboard_current():
|
||||||
|
if state.current_soundboard:
|
||||||
|
return jsonify({"soundboard": state.current_soundboard})
|
||||||
|
return jsonify({"soundboard": None}), 200
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route('/soundboard/status', methods=['GET'])
|
@api_bp.route('/soundboard/status', methods=['GET'])
|
||||||
def api_soundboard_status():
|
def api_soundboard_status():
|
||||||
with auto_random_lock:
|
with auto_random_lock:
|
||||||
@ -462,6 +471,7 @@ def api_soundboard_status():
|
|||||||
imax = auto_random_params.get('imax')
|
imax = auto_random_params.get('imax')
|
||||||
dmin = auto_random_params.get('dmin')
|
dmin = auto_random_params.get('dmin')
|
||||||
dmax = auto_random_params.get('dmax')
|
dmax = auto_random_params.get('dmax')
|
||||||
|
current_theme = state.current_soundboard.get('filename') if state.current_soundboard else None
|
||||||
next_seconds = max(0, next_ts - time.time()) if next_ts else None
|
next_seconds = max(0, next_ts - time.time()) if next_ts else None
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"active": active,
|
"active": active,
|
||||||
@ -469,7 +479,8 @@ def api_soundboard_status():
|
|||||||
"interval_min": imin,
|
"interval_min": imin,
|
||||||
"interval_max": imax,
|
"interval_max": imax,
|
||||||
"delay_min": dmin,
|
"delay_min": dmin,
|
||||||
"delay_max": dmax
|
"delay_max": dmax,
|
||||||
|
"current_theme": current_theme
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -269,10 +269,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Autoload erstes Thema (falls vorhanden)
|
// Autoload erstes Thema (falls vorhanden)
|
||||||
|
// Reihenfolge: Status prüfen, dann ggf. Theme laden
|
||||||
|
(async () => {
|
||||||
|
await updateAutoStatus();
|
||||||
if (selectEl && selectEl.value) {
|
if (selectEl && selectEl.value) {
|
||||||
|
// Wenn bereits ein Theme aktiv ist, nicht erneut laden (würde Auto stoppen)
|
||||||
|
const statusRes = await fetch('/api/soundboard/status');
|
||||||
|
const statusData = await statusRes.json();
|
||||||
|
if (!statusData.active || statusData.current_theme !== selectEl.value) {
|
||||||
loadSoundboard(selectEl.value);
|
loadSoundboard(selectEl.value);
|
||||||
} else {
|
} else {
|
||||||
updateAutoStatus();
|
// Theme-Daten nachladen ohne Auto zu stoppen
|
||||||
|
const cur = await fetch('/api/soundboard/current');
|
||||||
|
const curData = await cur.json();
|
||||||
|
if (curData.soundboard) {
|
||||||
|
currentSB = curData.soundboard;
|
||||||
|
renderSoundboard(currentSB);
|
||||||
|
content.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user