Skip to content
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

Merged
merged 16 commits into from
Oct 2, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reaname boolean fields for UserLocation
  • Loading branch information
soumyashisPR committed Aug 22, 2020
commit ccf3c1c6a0bf598d30a031e7b34fb08d657f8b1d
14 changes: 7 additions & 7 deletions javascript/components/UserLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ class UserLocation extends React.Component {
// after component unmount
_isMounted = null;

locationManagerRequired = false;
_isLocationManagerRequired = false;

async componentDidMount() {
this._isMounted = true;

await this.setLocationManager({
required: this.needsLocationManagerRunning(),
required: this.isLocationManagerRequired(),
});

if (this.renderMode === UserLocation.RenderMode.Native) {
Expand All @@ -155,7 +155,7 @@ class UserLocation extends React.Component {

async componentDidUpdate(prevProps) {
await this.setLocationManager({
required: this.needsLocationManagerRunning(),
required: this.isLocationManagerRequired(),
});

if (this.props.minDisplacement !== prevProps.minDisplacement) {
Expand All @@ -179,8 +179,8 @@ class UserLocation extends React.Component {
* @return {Promise<void>}
*/
async setLocationManager({required}) {
if (this.locationManagerRequired !== required) {
this.locationManagerRequired = required;
if (this._isLocationManagerRequired !== required) {
this._isLocationManagerRequired = required;
if (required) {
locationManager.addListener(this._onLocationUpdate);
} else {
Expand All @@ -191,11 +191,11 @@ class UserLocation extends React.Component {

/**
*
* If locationManager should be running
* If locationManager is required.
*
* @return {boolean}
*/
needsLocationManagerRunning() {
isLocationManagerRequired() {
ferdicus marked this conversation as resolved.
Show resolved Hide resolved
if (this.props.renderMode === UserLocation.RenderMode.Native) {
return false;
}
Expand Down