Skip to content

enh(strava): 🌟 adding Strava sync right away w/o interactivity if refresh token is valid#118

Draft
dvorka wants to merge 1 commit into
dev/1.58.0from
enh-20260627/strava-sync-directly
Draft

enh(strava): 🌟 adding Strava sync right away w/o interactivity if refresh token is valid#118
dvorka wants to merge 1 commit into
dev/1.58.0from
enh-20260627/strava-sync-directly

Conversation

@dvorka

@dvorka dvorka commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@dvorka dvorka self-assigned this Jun 27, 2026
@dvorka dvorka marked this pull request as draft June 30, 2026 16:06
@dvorka dvorka requested a review from Copilot July 1, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Strava “sync” navbar icon to trigger a one-click synchronization flow, aiming to start syncing immediately when credentials allow (with a fallback to the interactive Strava developer page when they don’t).

Changes:

  • Switch navbar sync icon to point to a new /strava/sync/menu route.
  • Add strava_sync_from_menu() route to start sync immediately when a refresh token is available, otherwise redirect to the interactive developer page.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
mytral/templates/layout.html Navbar Strava sync icon now targets the new one-click sync route.
mytral/blueprints/strava_api_uri_space.py Adds a new menu-triggered sync route that conditionally starts sync or redirects to the developer/auth flow.

{% if user_profile.strava_client_id and user_profile.strava_client_secret %}
<div class="nav-item">
<a href="{{ url_for('strava_api_developer') }}" class="nav-link px-0 position-relative" title="Synchronize activities w/ your favorite sport tracker service" data-bs-toggle="tooltip" data-bs-placement="bottom">
<a href="{{ url_for('strava_sync_from_menu') }}" class="nav-link px-0 position-relative" title="Synchronize activities w/ your favorite sport tracker service" data-bs-toggle="tooltip" data-bs-placement="bottom">
Comment on lines +140 to +146
"""One-click Strava sync triggered from the top-menu sync icon.

If a refresh token is available, authenticate silently (when the access
token is missing or expired) and start syncing new activities right away.
Without a refresh token, fall back to the interactive developer page so the
user can authenticate first - same as the Data / Import / Strava API flow.
"""
Comment on lines +147 to +150
user_id = flask.session.get(COOKIE_USER)
if not user_id:
return flask.redirect(flask.url_for("login"))
user_profile = ds.profile(user_id)
Comment on lines +152 to +157
# no refresh token -> keep the interactive flow on the developer page
if not strava.is_refresh_token_valid(user_profile):
return flask.redirect(flask.url_for("strava_api_developer"))

# refresh token available -> start the sync (silent refresh handled inside)
return strava_sync_new_to_current()
@dvorka dvorka changed the base branch from dev/1.57.0 to dev/1.58.0 July 6, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants