From 95638c6e4181390e384b475834c8db2f2a849ab6 Mon Sep 17 00:00:00 2001 From: yihong Date: Sun, 3 Mar 2024 15:57:05 +0800 Subject: [PATCH] fix: ts type error (#622) Signed-off-by: yihong0618 --- .github/workflows/ci.yml | 2 +- Dockerfile | 2 -- package.json | 2 ++ pnpm-lock.yaml | 20 +++++++++++++------- src/components/RunMap/LightsControl.tsx | 1 - src/components/RunMap/index.tsx | 2 +- src/hooks/useHover.ts | 2 +- src/utils/utils.ts | 16 +++++++++------- 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index add07e25071..c67c4d26ef3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 diff --git a/Dockerfile b/Dockerfile index 684004d4391..08b4489913f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,6 @@ RUN npm config set registry https://registry.npm.taobao.org \ &&corepack enable \ &&pnpm install - - FROM develop-py AS data ARG app ARG nike_refresh_token diff --git a/package.json b/package.json index 054204c055a..c707ff966fa 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,10 @@ "url": "https://github.com/yihong0618/running_page" }, "devDependencies": { + "@types/geojson": "^7946.0.14", "@types/mapbox__polyline": "^1.0.2", "@types/node": "^20.3.3", + "@types/prop-types": "^15.7.11", "@types/react": "^18.2.14", "@types/react-dom": "^18.2.6", "@typescript-eslint/parser": "^5.59.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6c5483dbf78..94cb3b52c33 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -76,12 +76,18 @@ dependencies: version: 4.2.0(typescript@5.2.2)(vite@4.4.9) devDependencies: + '@types/geojson': + specifier: ^7946.0.14 + version: 7946.0.14 '@types/mapbox__polyline': specifier: ^1.0.2 version: 1.0.2 '@types/node': specifier: ^20.3.3 version: 20.5.7 + '@types/prop-types': + specifier: ^15.7.11 + version: 15.7.11 '@types/react': specifier: ^18.2.14 version: 18.2.21 @@ -889,19 +895,19 @@ packages: resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} dev: false - /@types/geojson@7946.0.10: - resolution: {integrity: sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==} + /@types/geojson@7946.0.14: + resolution: {integrity: sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==} /@types/mapbox-gl@2.7.13: resolution: {integrity: sha512-qNffhTdYkeFl8QG9Q1zPPJmcs8PvHgmLa1PcwP1rxvcfMsIgcFr/FnrCttG0ZnH7Kzdd7xfECSRNTWSr4jC3PQ==} dependencies: - '@types/geojson': 7946.0.10 + '@types/geojson': 7946.0.14 dev: false /@types/mapbox__polyline@1.0.2: resolution: {integrity: sha512-Kr/oznVL3e8uvWM0+VPlVu2rVP+jKyVW/994HE9YJFBfcAcKqB4wMvqCdgXLG0SSrxxlKc5Nqaj7zt+KRl9oCA==} dependencies: - '@types/geojson': 7946.0.10 + '@types/geojson': 7946.0.14 dev: true /@types/minimist@1.2.2: @@ -915,8 +921,8 @@ packages: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: false - /@types/prop-types@15.7.5: - resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} + /@types/prop-types@15.7.11: + resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==} dev: true /@types/react-dom@18.2.7: @@ -928,7 +934,7 @@ packages: /@types/react@18.2.21: resolution: {integrity: sha512-neFKG/sBAwGxHgXiIxnbm3/AAVQ/cMRS93hvBpg8xYRbeQSPVABp9U2bRnPf0iI4+Ucdv3plSxKK+3CW2ENJxA==} dependencies: - '@types/prop-types': 15.7.5 + '@types/prop-types': 15.7.11 '@types/scheduler': 0.16.3 csstype: 3.1.2 dev: true diff --git a/src/components/RunMap/LightsControl.tsx b/src/components/RunMap/LightsControl.tsx index b37360664cb..da23d2f9473 100644 --- a/src/components/RunMap/LightsControl.tsx +++ b/src/components/RunMap/LightsControl.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import styles from './style.module.scss'; interface ILightsProps { diff --git a/src/components/RunMap/index.tsx b/src/components/RunMap/index.tsx index fd9ab60b6b1..b36c3fe4193 100644 --- a/src/components/RunMap/index.tsx +++ b/src/components/RunMap/index.tsx @@ -48,7 +48,7 @@ const RunMap = ({ const keepWhenLightsOff = ['runs2'] function switchLayerVisibility(map: MapInstance, lights: boolean) { const styleJson = map.getStyle(); - styleJson.layers.forEach(it => { + styleJson.layers.forEach((it: { id: string; }) => { if (!keepWhenLightsOff.includes(it.id)) { if (lights) map.setLayoutProperty(it.id, 'visibility', 'visible'); diff --git a/src/hooks/useHover.ts b/src/hooks/useHover.ts index facc287c2b5..aa9df373d98 100644 --- a/src/hooks/useHover.ts +++ b/src/hooks/useHover.ts @@ -8,7 +8,7 @@ const useHover = (): HoverHook => { const eventHandlers = { onMouseOver() { - setTimer(setTimeout(() => setHovered(true), 700)); + setTimer(setTimeout(() => setHovered(true), 500)); // 500ms delay }, onMouseOut() { clearTimeout(timer); diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 80d5d157327..1c980b35668 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -15,12 +15,12 @@ export interface Activity { name: string; distance: number; moving_time: string; - type: 'Run'; + type: string; start_date: string; start_date_local: string; - location_country: string; - summary_polyline: string; - average_heartrate?: number; + location_country?: string|null; + summary_polyline?: string|null; + average_heartrate?: number|null; average_speed: number; streak: number; } @@ -147,6 +147,9 @@ const intComma = (x = '') => { const pathForRun = (run: Activity): Coordinate[] => { try { + if (!run.summary_polyline) { + return []; + }; const c = mapboxPolyline.decode(run.summary_polyline); // reverse lat long for mapbox c.forEach((arr) => { @@ -271,10 +274,9 @@ const filterAndSortRuns = ( }; const sortDateFunc = (a: Activity, b: Activity) => { - // @ts-ignore return ( - new Date(b.start_date_local.replace(' ', 'T')) - - new Date(a.start_date_local.replace(' ', 'T')) + new Date(b.start_date_local.replace(' ', 'T')).getTime() - + new Date(a.start_date_local.replace(' ', 'T')).getTime() ); }; const sortDateFuncReverse = (a: Activity, b: Activity) => sortDateFunc(b, a);