Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fetch client country code and write to app state #541

Merged
merged 1 commit into from May 29, 2019

Conversation

jwalgran
Copy link
Contributor

@jwalgran jwalgran commented May 28, 2019

Overview

We need to detect if someone is browsing the app from China so that we can
change the way in which we load our map components. To facilitate this we make a
request to the free userinfo.io service when the App component loads and save
the returned country to the app state.

Connects #538

Demo

The userinfo.io service returning the correct country with the China VPN connection.

Screen Shot 2019-05-28 at 2 51 26 PM

Writing country to app state

Screen Shot 2019-05-28 at 2 54 21 PM

Setting fetched flag on failure

Screen Shot 2019-05-28 at 2 56 54 PM

Testing Instructions

  • Open developer tools and browse http://localhost:6543/. Verify that clientInfo.countryCode is set in the app state.

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

@jwalgran jwalgran requested a review from kellyi May 28, 2019 22:15
@jwalgran jwalgran assigned jwalgran and kellyi and unassigned jwalgran May 28, 2019
[completeFetchClientInfo]: (state, payload) => update(state, {
fetched: { $set: true },
countryCode: { $set: payload.country.code }
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would there ever be a need to clear this during the running of the app? It seems like the answer is no but I thought I'd check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we would ever need to clear the fetched client info.

We need to detect if someone is browsing the app from China so that we can
change the way in which we load our map components. To facilitate this we make a
request to the free userinfo.io service when the `App` component loads and save
the returned country to the app state.
Copy link
Contributor

@kellyi kellyi left a comment

Choose a reason for hiding this comment

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

👍

Screen Shot 2019-05-29 at 10 26 38 AM

@kellyi kellyi assigned jwalgran and unassigned kellyi May 29, 2019
@jwalgran
Copy link
Contributor Author

Thanks for the review

@jwalgran jwalgran merged commit 490d286 into develop May 29, 2019
@jwalgran jwalgran deleted the jcw/fetch-client-info branch May 29, 2019 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants