From ef944e4ffebfd0d13653655734a9316d1ecd658a Mon Sep 17 00:00:00 2001 From: Phlogi Date: Fri, 22 Aug 2025 22:06:42 +0200 Subject: [PATCH 1/3] Revert "fixup: NoneType Float Issue" This reverts commit 9dc0deafa49a54bf3b7539b32c37b26ce7bf0484. --- routes/system/progress.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/system/progress.py b/routes/system/progress.py index c6cbc58..465407d 100755 --- a/routes/system/progress.py +++ b/routes/system/progress.py @@ -4,7 +4,7 @@ import logging import time import json import asyncio -from typing import Dict, Set, Optional +from typing import Dict, Set from routes.utils.celery_tasks import ( get_task_info, @@ -141,7 +141,7 @@ def start_sse_redis_subscriber(): thread.start() logger.info("SSE Redis Subscriber: Background thread started") -async def transform_callback_to_task_format(task_id: str, event_data: dict) -> Optional[dict]: +async def transform_callback_to_task_format(task_id: str, event_data: dict) -> dict: """Transform callback event data into the task format expected by frontend""" try: # Import here to avoid circular imports @@ -646,7 +646,7 @@ async def list_tasks(request: Request, current_user: User = Depends(require_auth other_tasks.append(task_response) # Sort other tasks by creation time (newest first) - other_tasks.sort(key=lambda x: x.get("created_at") or 0.0, reverse=True) + other_tasks.sort(key=lambda x: x.get("created_at", 0), reverse=True) if active_only: # Return only active tasks without pagination @@ -876,7 +876,7 @@ async def cancel_task_endpoint(task_id: str, current_user: User = Depends(requir try: # Push an immediate SSE update so clients reflect cancellation and partial summary await trigger_sse_update(task_id, "cancelled") - result["sse_notified"] = "true" + result["sse_notified"] = True except Exception as e: logger.error(f"SSE notify after cancel failed for {task_id}: {e}") return result From 99eb84372faf5f7fec031308b7487142b04673ab Mon Sep 17 00:00:00 2001 From: Phlogi Date: Fri, 22 Aug 2025 22:09:58 +0200 Subject: [PATCH 2/3] small comment update --- spotizerr-ui/src/components/config/AccountsTab.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotizerr-ui/src/components/config/AccountsTab.tsx b/spotizerr-ui/src/components/config/AccountsTab.tsx index f2d52c8..62feec6 100644 --- a/spotizerr-ui/src/components/config/AccountsTab.tsx +++ b/spotizerr-ui/src/components/config/AccountsTab.tsx @@ -85,7 +85,7 @@ export function AccountsTab() { onSuccess: () => { toast.success("Account added successfully!"); queryClient.invalidateQueries({ queryKey: ["credentials", activeService] }); - queryClient.invalidateQueries({ queryKey: ["config"] }); // Invalidate config to update active Spotify account in UI + queryClient.invalidateQueries({ queryKey: ["config"] }); // Invalidate config to update active Spotify/Deezer account in UI setIsAdding(false); setSubmitError(null); reset(); From afb7caa2b4411bc35eddde7e51e3abdbfd43db2b Mon Sep 17 00:00:00 2001 From: Phlogi Date: Fri, 22 Aug 2025 22:10:14 +0200 Subject: [PATCH 3/3] helper function --- routes/auth/credentials.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/routes/auth/credentials.py b/routes/auth/credentials.py index 8b8496f..6427933 100755 --- a/routes/auth/credentials.py +++ b/routes/auth/credentials.py @@ -23,6 +23,22 @@ router = APIRouter() init_credentials_db() +def _set_active_account_if_empty(service: str, name: str): + """ + Sets the newly created account as the active account in the main config + if no active account is currently set for the given service. + """ + try: + from routes.utils.celery_config import get_config_params as get_main_config_params + from routes.system.config import save_config + config = get_main_config_params() + if not config.get(service): + config[service] = name + save_config(config) + except Exception as e: + logger.warning(f"Could not set new {service.capitalize()} account '{name}' as active: {e}") + + @router.get("/spotify_api_config") @router.put("/spotify_api_config") async def handle_spotify_api_config(request: Request, current_user: User = Depends(require_admin_from_state)): @@ -130,18 +146,7 @@ async def handle_create_credential(service: str, name: str, request: Request, cu # Validation is handled within create_credential utility function result = create_credential(service, name, data) - # set as active Spotify account if none is set - if service == "spotify": - try: - from routes.utils.celery_config import get_config_params as get_main_config_params - from routes.system.config import save_config - config = get_main_config_params() - # The field is likely "spotify" (as used in frontend) - if not config.get("spotify"): - config["spotify"] = name - save_config(config) - except Exception as e: - logger.warning(f"Could not set new Spotify account '{name}' as active: {e}") + _set_active_account_if_empty(service, name) return { "message": f"Credential for '{name}' ({service}) created successfully.",