Skip to content

Commit

Permalink
Fix incorrect deserialization of app state if user has never moved fr…
Browse files Browse the repository at this point in the history
…om original position. Fix delayed display of inventory after deserialization.
  • Loading branch information
blujai831 committed Nov 14, 2024
1 parent 5582180 commit 4d8cbb7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,18 +498,21 @@ function deserializeAppState(
for (const coin of mementoObject.coinsOwned) {
appState.coinsOwned.push(coin);
}
const latLng = mementoObject.locationHistory[
mementoObject.locationHistory.length - 1
];
const leafletLatLng = leaflet.latLng(latLng.lat, latLng.lng);
moveUserMarkerToLatLng(appState, uiOut, leafletLatLng);
if (mementoObject.locationHistory.length > 0) {
const latLng = mementoObject.locationHistory[
mementoObject.locationHistory.length - 1
];
const leafletLatLng = leaflet.latLng(latLng.lat, latLng.lng);
moveUserMarkerToLatLng(appState, uiOut, leafletLatLng);
}
appState.locationHistory.length = 0;
appState.polyline.setLatLngs([]);
for (const latLng of mementoObject.locationHistory) {
const leafletLatLng = leaflet.latLng(latLng.lat, latLng.lng);
appState.locationHistory.push(leafletLatLng);
appState.polyline.addLatLng(leafletLatLng);
}
updateInventoryStatus(appState, uiOut);
}

// UI
Expand Down

0 comments on commit 4d8cbb7

Please sign in to comment.