Skip to content

Commit

Permalink
switched strava to proxied service (fixes #532)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdila committed Sep 21, 2020
1 parent d8894f3 commit 375bdd9
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 56 deletions.
2 changes: 0 additions & 2 deletions src/actions/mapActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ export const mapSetOverlayOpacity = createAction('MAP_SET_OVERLAY_OPACITY')<{
export const mapSetOverlayPaneOpacity = createAction(
'MAP_SET_OVERLAY_PANE_OPACITY',
)<number>();

export const mapSetStravaAuth = createAction('MAP_SET_STRAVA_AUTH')<boolean>();
27 changes: 3 additions & 24 deletions src/components/MapSwitchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const MapSwitchButtonInt: React.FC<Props> = ({
expertMode,
zoom,
pictureFilterIsActive,
stravaAuth,
onMapRefocus,
language,
}) => {
Expand Down Expand Up @@ -57,14 +56,7 @@ const MapSwitchButtonInt: React.FC<Props> = ({
);

const handleOverlaySelect = useCallback(
(overlay: any, e: React.SyntheticEvent<any>) => {
const { dataset } = e.target as HTMLElement;

if (dataset && dataset.strava) {
window.open('https://www.strava.com/heatmap');
return;
}

(overlay: any) => {
const s = new Set(overlays);

if (s.has(overlay)) {
Expand Down Expand Up @@ -207,7 +199,7 @@ const MapSwitchButtonInt: React.FC<Props> = ({
!showOnlyInExpertMode || expertMode,
)
.filter(({ adminOnly }) => isAdmin || !adminOnly)
.map(({ type, icon, minZoom, key, strava }) => (
.map(({ type, icon, minZoom, key }) => (
<MenuItem
key={type}
eventKey={type}
Expand All @@ -228,8 +220,7 @@ const MapSwitchButtonInt: React.FC<Props> = ({
<span
style={{
textDecoration:
(minZoom !== undefined && zoom < minZoom) ||
(strava && !stravaAuth)
minZoom !== undefined && zoom < minZoom
? 'line-through'
: 'none',
}}
Expand All @@ -250,17 +241,6 @@ const MapSwitchButtonInt: React.FC<Props> = ({
/>
</>
)}
{strava && !stravaAuth && (
<>
{' '}
<FontAwesomeIcon
data-strava
icon="exclamation-triangle"
title={t('mapLayers.missingStravaAuth')}
className="text-warning"
/>
</>
)}
{type === 'I' && pictureFilterIsActive && (
<>
{' '}
Expand Down Expand Up @@ -289,7 +269,6 @@ const mapStateToProps = (state: RootState) => ({
(key) => state.gallery.filter[key],
),
isAdmin: !!(state.auth.user && state.auth.user.isAdmin),
stravaAuth: state.map.stravaAuth,
language: state.l10n.language,
});

Expand Down
14 changes: 0 additions & 14 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
setEmbedFeatures,
} from 'fm3/actions/mainActions';
// import { errorSetError } from 'fm3/actions/errorActions';
import { mapSetStravaAuth } from 'fm3/actions/mapActions';
import { l10nSetChosenLanguage } from 'fm3/actions/l10nActions';

import { history } from 'fm3/historyHolder';
Expand Down Expand Up @@ -65,8 +64,6 @@ attachOsmLoginMessageHandler(store);

store.dispatch(enableUpdatingUrl());

checkStravaAuth();

render(
<Provider store={store}>
<ErrorCatcher>
Expand Down Expand Up @@ -117,14 +114,3 @@ window.addEventListener('message', (e: MessageEvent) => {
store.dispatch(authCheckLogin());

attachKeyboardHandler(store);

function checkStravaAuth() {
const img = new Image();

img.onload = () => {
store.dispatch(mapSetStravaAuth(true));
};

img.src =
'https://heatmap-external-a.strava.com/tiles-auth/both/bluered/16/36718/22612.png';
}
2 changes: 1 addition & 1 deletion src/mapDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export const overlayLayers: LayerDef[] = [
...['both', 'ride', 'run', 'water', 'winter'].map((type, i) => ({
type: `s${i}`,
icon: 'scribd', // TODO use correct logo
url: `//heatmap-external-{s}.strava.com/tiles-auth/${type}/bluered/{z}/{x}/{y}.png?px=256`,
url: `//strava-heatmap.tiles.freemap.sk/${type}/bluered/{z}/{x}/{y}.png?px=256`,
attribution: [STRAVA_ATTR],
minZoom: 0,
maxNativeZoom: 16,
Expand Down
7 changes: 0 additions & 7 deletions src/reducers/mapReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import {
mapReset,
mapSetOverlayOpacity,
mapSetOverlayPaneOpacity,
mapSetStravaAuth,
} from 'fm3/actions/mapActions';
import { RootAction } from 'fm3/actions';
import { authSetUser } from 'fm3/actions/authActions';
import { selectFeature, setAppState, Selection } from 'fm3/actions/mainActions';
import { mapsDataLoaded } from 'fm3/actions/mapsActions';

export interface MapState extends MapStateBase {
stravaAuth: boolean;
selection: Selection | null;
removeGalleryOverlayOnGalleryToolQuit: boolean;
gpsTracked: boolean;
Expand All @@ -27,7 +25,6 @@ const initialState: MapState = {
overlays: [],
overlayOpacity: {},
overlayPaneOpacity: 0.75,
stravaAuth: false,
selection: null,
removeGalleryOverlayOnGalleryToolQuit: false,
gpsTracked: false,
Expand Down Expand Up @@ -97,10 +94,6 @@ export const mapReducer = createReducer<MapState, RootAction>(initialState)
}
: state;
})
.handleAction(mapSetStravaAuth, (state, action) => ({
...state,
stravaAuth: action.payload,
}))
.handleAction(selectFeature, (state, action) => {
const currentSelection = state.selection;
const nextSelection = action.payload;
Expand Down
2 changes: 0 additions & 2 deletions src/translations/cs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,6 @@ export default {
},

mapLayers: {
missingStravaAuth:
'Prosím přihlašte se nejprve na strava.com/heatmap (klikněte na vykřičník) a následně obnovte tuto stránku.',
layers: 'Vrstvy',
photoFilterWarning: 'Filtr fotografií je aktivní',
minZoomWarning: 'Dostupné až od přiblížení {minZoom}',
Expand Down
2 changes: 0 additions & 2 deletions src/translations/en.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,6 @@ export default {
},

mapLayers: {
missingStravaAuth:
'Please log-in on strava.com/heatmap first (click on the exclamation mark) and then reload this page.',
layers: 'Map layers',
photoFilterWarning: 'Photo filtering is active',
minZoomWarning: 'Accessible from zoom {minZoom}',
Expand Down
2 changes: 0 additions & 2 deletions src/translations/hu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,6 @@ export default {
},

mapLayers: {
missingStravaAuth:
'Először jelentkezzék be a www.strava.com/heatmap oldalon, majd frissítse az oldalt.',
layers: 'Térképrétegek',
photoFilterWarning: 'A fényképszűrés aktív',
minZoomWarning: 'A {minZoom} nagyítási szinttől látható.',
Expand Down
2 changes: 0 additions & 2 deletions src/translations/sk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,6 @@ export default {
},

mapLayers: {
missingStravaAuth:
'Prosím prihláste sa najprv na strava.com/heatmap (kliknite na výkričník) a následne obnovte túto stránku.',
layers: 'Vrstvy',
photoFilterWarning: 'Filter fotografií je aktívny',
minZoomWarning: 'Dostupné až od priblíženia {minZoom}',
Expand Down

0 comments on commit 375bdd9

Please sign in to comment.