Here's a summary of all fixes:
Issue #4 — Skip not clearing med File: synculous-client/src/app/dashboard/medications/page.tsx Root cause: Skipped medications were routed to the "Upcoming" section (status === 'skipped' in the upcoming condition), so they appeared as if still pending. Fix: Removed || status === 'skipped' from the grouping condition. Now skipped meds go to the "Due" section where they properly render with the "Skipped" label — same pattern as taken meds showing "Taken". Issue #5 — "Invested -359m in yourself" Files: api/routes/routines.py, synculous-client/src/app/dashboard/page.tsx, synculous-client/src/app/dashboard/stats/page.tsx Root cause: Session duration was calculated by comparing a naive UTC created_at from PostgreSQL with the user's local time (after stripping timezone). For users behind UTC (e.g., CST/UTC-6), this produced negative durations (~-359 minutes ≈ -6 hours offset). Fix: Added _make_aware_utc() helper that treats naive datetimes as UTC before comparison. Also clamped durations to max(0, ...) on both backend and frontend formatTime as a safety net. Issue #6 — Push notifications not working File: api/routes/notifications.py Root cause: Subscribing to push notifications created a push_subscriptions row but never set web_push_enabled: true in the notifications table. The scheduler daemon checks web_push_enabled before sending, so push notifications were always skipped. Fix: When subscribing, also call notifications.setNotificationSettings() to enable web_push_enabled. When unsubscribing (and no subscriptions remain), disable it.
This commit is contained in:
@@ -9,6 +9,7 @@ import flask
|
||||
import jwt
|
||||
import core.auth as auth
|
||||
import core.postgres as postgres
|
||||
import core.notifications as notifications
|
||||
|
||||
|
||||
def _get_user_uuid(token):
|
||||
@@ -75,6 +76,8 @@ def register(app):
|
||||
"auth": auth_key,
|
||||
}
|
||||
postgres.insert("push_subscriptions", row)
|
||||
# Ensure web_push_enabled is set in notifications settings
|
||||
notifications.setNotificationSettings(user_uuid, {"web_push_enabled": True})
|
||||
return flask.jsonify({"subscribed": True}), 201
|
||||
|
||||
@app.route("/api/notifications/subscribe", methods=["DELETE"])
|
||||
@@ -91,4 +94,8 @@ def register(app):
|
||||
"user_uuid": user_uuid,
|
||||
"endpoint": data["endpoint"],
|
||||
})
|
||||
# If no subscriptions remain, disable web push
|
||||
remaining = postgres.select("push_subscriptions", where={"user_uuid": user_uuid})
|
||||
if not remaining:
|
||||
notifications.setNotificationSettings(user_uuid, {"web_push_enabled": False})
|
||||
return flask.jsonify({"unsubscribed": True}), 200
|
||||
|
||||
Reference in New Issue
Block a user