-
-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 915: Stop/start Location manager based on listeners registered. #999
Changes from 15 commits
54c500e
2a19415
8af090c
5cf5ee9
f2550ae
ccf3c1c
b61268b
ed46202
5491ca3
b11ac63
6da74f7
41f282b
0df8663
ac280cc
3c469a8
1d398f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,8 +142,6 @@ class UserLocation extends React.Component { | |
async componentDidMount() { | ||
this._isMounted = true; | ||
|
||
locationManager.addListener(this._onLocationUpdate); | ||
|
||
await this.setLocationManager({ | ||
running: this.needsLocationManagerRunning(), | ||
}); | ||
|
@@ -167,14 +165,13 @@ class UserLocation extends React.Component { | |
|
||
async componentWillUnmount() { | ||
this._isMounted = false; | ||
locationManager.removeListener(this._onLocationUpdate); | ||
mfazekas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await this.setLocationManager({running: false}); | ||
} | ||
|
||
/** | ||
* Whether to start or stop the locationManager | ||
* Whether to start or stop listening to the locationManager | ||
* | ||
* Notice, that locationManager will start automatically when | ||
* Notice, that listening will start automatically when | ||
* either `onUpdate` or `visible` are set | ||
* | ||
* @async | ||
|
@@ -185,12 +182,11 @@ class UserLocation extends React.Component { | |
if (this.locationManagerRunning !== running) { | ||
this.locationManagerRunning = running; | ||
if (running) { | ||
locationManager.start(); | ||
|
||
locationManager.addListener(this._onLocationUpdate); | ||
const location = await locationManager.getLastKnownLocation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed this the last time around, I think you can remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, this is actually being used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean... yeah, now it does after you reverted it again :) |
||
this._onLocationUpdate(location); | ||
} else { | ||
locationManager.stop(); | ||
locationManager.removeListener(this._onLocationUpdate); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 're-add' make more sense here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.