0002-View-on-Strava.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From cc91520e76079555bee24360d42610b7cbc246b3 Mon Sep 17 00:00:00 2001
  2. From: Mark Liversedge <liversedge@gmail.com>
  3. Date: Fri, 17 Jan 2020 12:30:29 +0000
  4. Subject: View on Strava
  5. .. when data is downloaded from strava we now set the metadata
  6. tag "StravaID" to the id of the activity on Strava.
  7. .. On RideSummary a link is added at the bottom to view the activity
  8. on Strava if the "StravaID" is set.
  9. .. if the user clicks on the link the summary is replaced with the
  10. strava page for the ride:
  11. e.g. https://www.strava.com/activities/962515512
  12. .. this is part of a couple of updates to comply with the Strava
  13. guidelines for consumption of the Strava v3 API, see:
  14. https://developers.strava.com/guidelines/
  15. diff --git a/src/Charts/RideSummaryWindow.cpp b/src/Charts/RideSummaryWindow.cpp
  16. index 1906ef1f3..37de8244d 100644
  17. --- a/src/Charts/RideSummaryWindow.cpp
  18. +++ b/src/Charts/RideSummaryWindow.cpp
  19. @@ -1517,6 +1517,12 @@ RideSummaryWindow::htmlSummary()
  20. summary += " <li>" + i.next();
  21. summary += "</ul>";
  22. }
  23. +
  24. + // add link to view on Strava if was downloaded from there (StravaID will be set)
  25. + if (ridesummary && rideItem && rideItem->ride() && rideItem->ride()->getTag("StravaID","") != "") {
  26. + summary += "<a href=\"https://www.strava.com/activities/" + rideItem->ride()->getTag("StravaID","") + "\">View on Strava</a>";
  27. + }
  28. +
  29. summary += "<br></center>";
  30. return summary;
  31. diff --git a/src/Cloud/Strava.cpp b/src/Cloud/Strava.cpp
  32. index 0b339ac98..fe03e9eba 100644
  33. --- a/src/Cloud/Strava.cpp
  34. +++ b/src/Cloud/Strava.cpp
  35. @@ -859,6 +859,9 @@ Strava::prepareResponse(QByteArray* data)
  36. // 1s samples with start time
  37. RideFile *ride = new RideFile(starttime.toUTC(), 1.0f);
  38. + // set strava id in metadata (to show where we got it from - to add View on Strava link in Summary view
  39. + if (!each["id"].isNull()) ride->setTag("StravaID", QString("%1").arg(each["id"].toVariant().toULongLong()));
  40. +
  41. // what sport?
  42. if (!each["type"].isNull()) {
  43. QString stype = each["type"].toString();