feat: Add sorting by name for soundboard sounds and improve socket emission logging
This commit is contained in:
@@ -29,6 +29,9 @@ def get_sounds():
|
||||
# Get sounds from database
|
||||
sounds = Sound.find_by_type(sound_type)
|
||||
|
||||
# Order by name
|
||||
sounds = sorted(sounds, key=lambda s: s.name.lower())
|
||||
|
||||
# Convert to dict format
|
||||
sounds_data = [sound.to_dict() for sound in sounds]
|
||||
|
||||
@@ -65,13 +68,19 @@ def play_sound(sound_id: int):
|
||||
# Emit sound_changed event to all connected clients
|
||||
try:
|
||||
from app.services.socketio_service import SocketIOService
|
||||
SocketIOService.emit_sound_play_count_changed(sound_id, sound.play_count)
|
||||
|
||||
SocketIOService.emit_sound_play_count_changed(
|
||||
sound_id, sound.play_count
|
||||
)
|
||||
except Exception as e:
|
||||
# Don't fail the request if socket emission fails
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning(f"Failed to emit sound_play_count_changed event: {e}")
|
||||
|
||||
logger.warning(
|
||||
f"Failed to emit sound_play_count_changed event: {e}"
|
||||
)
|
||||
|
||||
return jsonify({"message": "Sound playing", "sound_id": sound_id})
|
||||
return (
|
||||
jsonify({"error": "Sound not found or cannot be played"}),
|
||||
|
||||
Reference in New Issue
Block a user