enh(strava): 🌟 adding Strava sync right away w/o interactivity if refresh token is valid#118
Draft
dvorka wants to merge 1 commit into
Draft
enh(strava): 🌟 adding Strava sync right away w/o interactivity if refresh token is valid#118dvorka wants to merge 1 commit into
dvorka wants to merge 1 commit into
Conversation
…resh token is valid
Contributor
There was a problem hiding this comment.
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/menuroute. - 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.