Skip to content

Commit d6457d7

Browse files
committed
fix: reset geolocation stage after login to prevent stuck state
- Add reset parameter to getInitialLocation() to reset currentStage - Fix bug where geolocation wouldn't work after login due to persistent currentStage - Ensure getNearestUnits() is called properly on subsequent app sessions - Pass reset=true explicitly when calling getInitialLocation in Main component
1 parent 52dc48a commit d6457d7

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/Main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AppComponent extends React.Component {
4545
if (services) {
4646
this.props.getNearestUnits(position, services, this.props.maintenanceOrganization);
4747
}
48-
});
48+
}, true);
4949
}
5050

5151
render() {

src/lib/geolocation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function createSuccessCallback(callback) {
3737
return (position) => {
3838
currentStage++;
3939
if (currentStage < _.size(POSITION_OPTIONS) - 1) {
40-
getInitialLocation(callback);
40+
getInitialLocation(callback, false); // Don't reset on subsequent calls
4141
}
4242
callback(position);
4343
};
@@ -46,10 +46,15 @@ function createSuccessCallback(callback) {
4646
function error() {
4747
}
4848

49-
export function getInitialLocation(callback) {
49+
export function getInitialLocation(callback, reset = true) {
5050
if (DISABLED) {
5151
return;
5252
}
53+
// Reset stage for new geolocation session
54+
if (reset) {
55+
currentStage = 0;
56+
}
57+
5358
const options = POSITION_OPTIONS[STAGES[currentStage]];
5459
if (options) {
5560
navigator.geolocation.getCurrentPosition(createSuccessCallback(callback), error, options);

0 commit comments

Comments
 (0)