From f538fbceb0904181c8d05ea447edae7c4559d088 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Mar 2026 10:20:00 +0000 Subject: [PATCH] Fix: add show_reading_timer user preference to API Closes zeeguu/web#965 (API side) Add SHOW_READING_TIMER constant to UserPreference model and handle it in the save_user_preferences endpoint so the frontend can persist the timer visibility setting across sessions. --- zeeguu/api/endpoints/user_preferences.py | 10 ++++++++++ zeeguu/core/model/user_preference.py | 1 + 2 files changed, 11 insertions(+) diff --git a/zeeguu/api/endpoints/user_preferences.py b/zeeguu/api/endpoints/user_preferences.py index 9dd95f55..7392adce 100644 --- a/zeeguu/api/endpoints/user_preferences.py +++ b/zeeguu/api/endpoints/user_preferences.py @@ -94,6 +94,16 @@ def save_user_preferences(): show_mwe_hints.value = show_mwe_hints_value db_session.add(show_mwe_hints) + show_reading_timer_value = data.get(UserPreference.SHOW_READING_TIMER, None) + if show_reading_timer_value is not None: + show_reading_timer = UserPreference.find_or_create( + db_session, + user, + UserPreference.SHOW_READING_TIMER, + ) + show_reading_timer.value = show_reading_timer_value + db_session.add(show_reading_timer) + db_session.add(user) db_session.commit() return "OK" diff --git a/zeeguu/core/model/user_preference.py b/zeeguu/core/model/user_preference.py index c788cfd1..049104f2 100644 --- a/zeeguu/core/model/user_preference.py +++ b/zeeguu/core/model/user_preference.py @@ -42,6 +42,7 @@ class UserPreference(db.Model): MAX_WORDS_TO_SCHEDULE = "max_words_to_schedule" FILTER_DISTURBING_CONTENT = "filter_disturbing_content" # Filter violence/death/tragedy articles SHOW_MWE_HINTS = "show_mwe_hints" # Show hints for multi-word expressions + SHOW_READING_TIMER = "show_reading_timer" # Show timer in reader and exercises def __init__(self, user: User, key=None, value=None): self.user = user