From 1e10e62ee52336c6c38d8faf7886b93f625116c2 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Tue, 9 Aug 2022 07:01:04 -0400 Subject: [PATCH 1/2] Update Scan Cells - Rename remaining s2cell files to scan cells - Accounts for https://github.com/RealDeviceMap/RealDeviceMap/pull/388 --- src/components/markers/s2cell.js | 13 ------------- src/components/markers/scanCell.js | 13 +++++++++++++ src/components/popups/{S2cell.jsx => ScanCell.jsx} | 2 +- src/components/tiles/ScanCell.jsx | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 src/components/markers/s2cell.js create mode 100644 src/components/markers/scanCell.js rename src/components/popups/{S2cell.jsx => ScanCell.jsx} (95%) diff --git a/src/components/markers/s2cell.js b/src/components/markers/s2cell.js deleted file mode 100644 index bb8395ad2..000000000 --- a/src/components/markers/s2cell.js +++ /dev/null @@ -1,13 +0,0 @@ -export default function s2cellMarker(cellUpdated) { - const ago = new Date().getTime() - cellUpdated * 1000 - const value = ago <= 150000 ? 0 : Math.min((ago - 150000) / 750000, 1) - const hue = ((1 - value) * 120).toString(10) - - return { - fillColor: ['hsl(', hue, ',100%,50%)'].join(''), - color: 'black', - opacity: 0.75, - fillOpacity: 0.5, - weight: 0.5, - } -} diff --git a/src/components/markers/scanCell.js b/src/components/markers/scanCell.js new file mode 100644 index 000000000..f572ebdec --- /dev/null +++ b/src/components/markers/scanCell.js @@ -0,0 +1,13 @@ +export default function scanCellMarker(updated) { + const ago = Date.now() / 1000 - updated + const value = ago <= 1050 ? 0 : Math.min((ago - 1050) / 750, 1) + const hue = ((1 - value) * 120).toString(10) + + return { + fillColor: ['hsl(', hue, ',100%, 50%)'].join(''), + color: 'black', + opacity: 0.75, + fillOpacity: 0.5, + weight: 0.5, + } +} diff --git a/src/components/popups/S2cell.jsx b/src/components/popups/ScanCell.jsx similarity index 95% rename from src/components/popups/S2cell.jsx rename to src/components/popups/ScanCell.jsx index 8510753cd..b9bc5e0e2 100644 --- a/src/components/popups/S2cell.jsx +++ b/src/components/popups/ScanCell.jsx @@ -4,7 +4,7 @@ import { Trans, useTranslation } from 'react-i18next' import Utility from '@services/Utility' -export default function S2CellPopup({ cell, ts }) { +export default function ScanCellPopup({ cell, ts }) { const { t } = useTranslation() const { id, updated } = cell const lastUpdated = new Date(updated * 1000) diff --git a/src/components/tiles/ScanCell.jsx b/src/components/tiles/ScanCell.jsx index c21c1e624..1d02f3099 100644 --- a/src/components/tiles/ScanCell.jsx +++ b/src/components/tiles/ScanCell.jsx @@ -1,10 +1,10 @@ import React, { memo } from 'react' import { Polygon, Popup } from 'react-leaflet' -import PopupContent from '../popups/S2cell' -import marker from '../markers/s2cell' +import PopupContent from '../popups/ScanCell' +import marker from '../markers/scanCell' -const S2cellTile = ({ item, config, zoom, ts }) => +const ScanCellTile = ({ item, config, zoom, ts }) => zoom >= config.scanCellsZoom && ( @@ -18,4 +18,4 @@ const areEqual = (prev, next) => prev.item.updated === next.item.updated && prev.zoom === next.zoom -export default memo(S2cellTile, areEqual) +export default memo(ScanCellTile, areEqual) From ca23eebce882cbfa9ce89e69f9418201794e7199 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Tue, 9 Aug 2022 08:48:06 -0400 Subject: [PATCH 2/2] performance --- src/components/markers/scanCell.js | 3 +-- src/components/tiles/ScanCell.jsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/markers/scanCell.js b/src/components/markers/scanCell.js index f572ebdec..97456d0d7 100644 --- a/src/components/markers/scanCell.js +++ b/src/components/markers/scanCell.js @@ -1,5 +1,4 @@ -export default function scanCellMarker(updated) { - const ago = Date.now() / 1000 - updated +export default function scanCellMarker(ago) { const value = ago <= 1050 ? 0 : Math.min((ago - 1050) / 750, 1) const hue = ((1 - value) * 120).toString(10) diff --git a/src/components/tiles/ScanCell.jsx b/src/components/tiles/ScanCell.jsx index 1d02f3099..d9ec4bed5 100644 --- a/src/components/tiles/ScanCell.jsx +++ b/src/components/tiles/ScanCell.jsx @@ -6,7 +6,7 @@ import marker from '../markers/scanCell' const ScanCellTile = ({ item, config, zoom, ts }) => zoom >= config.scanCellsZoom && ( - +