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

[Geolocation] Fix getCurrentPosition #4764

Closed
wants to merge 1 commit into from
Closed

[Geolocation] Fix getCurrentPosition #4764

wants to merge 1 commit into from

Conversation

marcshilling
Copy link

Instantiates the _pendingRequests array before trying to add to it. As it currently stands, we try to add the pending request before the array is created. getCurrentPosition always fails on the first try.

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @nicklockwood, @brentvatne and @zjj010104 to be potential reviewers.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@marcshilling marcshilling changed the title [Geolocation] Make getCurrentPosition actually work... [Geolocation] Fix getCurrentPosition Dec 14, 2015
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 14, 2015
@@ -234,6 +233,7 @@ - (void)timeout:(NSTimer *)timer
selector:@selector(timeout:)
userInfo:request
repeats:NO];
_pendingRequests = [NSMutableArray new];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be

if (!_pendingRequests) {
  _pendingRequests = [NSMutableArray new];
}

Otherwise you're wiping out all previous requests each time you call getCurrentPosition().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicklockwood
Considered that, but it seemed like getCurrentPosition() was the only place that actually adds anything to the pendingRequests so I figured it wasn't necessary. Guess it doesn't hurt either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the only thing that adds to it, but what if you call getCurrentPosition() again before the first request returns?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call...updated!

@facebook-github-bot
Copy link
Contributor

@marcshilling updated the pull request.

@marcshilling
Copy link
Author

Squashed commits

@skevy
Copy link
Contributor

skevy commented Dec 16, 2015

@facebook-github-bot shipit

@skevy
Copy link
Contributor

skevy commented Dec 16, 2015

Thanks for updating @marcshilling and congrats on your first RN PR!

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/560069157482654/int_phab to review.

1 similar comment
@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/560069157482654/int_phab to review.

@ghost ghost closed this in f48dbbe Dec 16, 2015
@nathanhester82
Copy link

Thanks all so much!

@marcshilling marcshilling deleted the patch-1 branch December 27, 2015 22:42
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants