Skip to content

Commit 84aa21e

Browse files
committed
fixed triggering next location on unlock
1 parent 83cdf5e commit 84aa21e

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/components/points-of-interest/PointOfInterest.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ function PointOfInterest({
5151
);
5252
setProximity(distance);
5353
if (!unlocked && id === nextUnlockableId) {
54-
setUnlocked(distance < accuracy); // todo magic number/get from config
55-
destinationChanged();
54+
setUnlocked(distance < accuracy);
5655
}
5756
}
5857
}, [latitude, longitude, lat, long, geolocationAvailable]);
@@ -62,6 +61,7 @@ function PointOfInterest({
6261
return;
6362
}
6463
if (unlocked) {
64+
destinationChanged(id);
6565
const currentLocalStorage = localStorage.getItem("unlocked-experiences");
6666
if (currentLocalStorage) {
6767
// add to existing unlocked steps
@@ -72,7 +72,6 @@ function PointOfInterest({
7272
"unlocked-experiences",
7373
JSON.stringify(updateLocalStorage)
7474
);
75-
destinationChanged();
7675
} else {
7776
// add new "unlocked steps"
7877
localStorage.setItem("unlocked-experiences", JSON.stringify([id]));
@@ -118,7 +117,7 @@ function PointOfInterest({
118117
<span className="sr-only">Afstand</span>
119118
{/* todo this is slow and would benefit from loading screen / skeleton componenet */}
120119
<span className="text-md" id="distance">
121-
{proximity - accuracy} m
120+
{Math.round(proximity - accuracy)} m
122121
</span>
123122
</label>
124123
)}

src/components/routes/RoutePage.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,12 @@ function RoutePage() {
138138
}
139139
}, []);
140140

141-
const destinationChanged = () => {
141+
const destinationChanged = (newlyUnlockedId = null) => {
142142
if (pointsOfInterest) {
143-
const destinationPoint = getRelevantDestinationPoint(pointsOfInterest);
143+
const destinationPoint = getRelevantDestinationPoint(
144+
pointsOfInterest,
145+
newlyUnlockedId
146+
);
144147
if (destinationPoint.length === 0) {
145148
return setRouteComplete(true);
146149
}

src/util/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export function isExperienceIdInLocalstorage(experienceId) {
5959
return false;
6060
}
6161

62-
export function getRelevantDestinationPoint(pointsOfInterest) {
62+
export function getRelevantDestinationPoint(pointsOfInterest, newlyUnlockedId) {
6363
const poiArray = pointsOfInterest.filter((poi) => {
64-
return !isExperienceIdInLocalstorage(poi.id);
64+
return !isExperienceIdInLocalstorage(poi.id) && poi.id !== newlyUnlockedId;
6565
});
6666
return poiArray;
6767
}

0 commit comments

Comments
 (0)