diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 9958acf..5aeaa06 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1978,6 +1978,25 @@ function doUserSetReferrer(referrer, shouldClaim) { } }; } +function doUserSetCountry(country) { + return (dispatch, getState) => { + const state = getState(); + const user = selectUser(state); + Lbryio.call('user_country', 'set', { + country + }).then(() => { + const newUser = { ...user, + country + }; + dispatch({ + type: USER_FETCH_SUCCESS, + data: { + user: newUser + } + }); + }); + }; +} function doClaimYoutubeChannels() { return dispatch => { dispatch({ @@ -4042,6 +4061,7 @@ exports.doUserPhoneReset = doUserPhoneReset; exports.doUserPhoneVerify = doUserPhoneVerify; exports.doUserPhoneVerifyFailure = doUserPhoneVerifyFailure; exports.doUserResendVerificationEmail = doUserResendVerificationEmail; +exports.doUserSetCountry = doUserSetCountry; exports.doUserSetReferrer = doUserSetReferrer; exports.doUserSetReferrerReset = doUserSetReferrerReset; exports.doUserSignIn = doUserSignIn; diff --git a/flow-typed/User.js b/flow-typed/User.js index ec64170..5a06ff6 100644 --- a/flow-typed/User.js +++ b/flow-typed/User.js @@ -3,6 +3,7 @@ type DeviceType = 'mobile' | 'web' | 'desktop'; declare type User = { + country: ?string, created_at: string, family_name: ?string, given_name: ?string, diff --git a/src/index.js b/src/index.js index 3b1ceba..4413dea 100644 --- a/src/index.js +++ b/src/index.js @@ -74,6 +74,7 @@ export { doUserCheckIfEmailExists, doClearEmailEntry, doClearPasswordEntry, + doUserSetCountry, } from 'redux/actions/user'; export { doFetchCostInfoForUri } from 'redux/actions/cost_info'; export { doBlackListedOutpointsSubscribe } from 'redux/actions/blacklist'; diff --git a/src/redux/actions/user.js b/src/redux/actions/user.js index 4319585..bfdaddd 100644 --- a/src/redux/actions/user.js +++ b/src/redux/actions/user.js @@ -12,6 +12,7 @@ import { selectEmailToVerify, selectPhoneToVerify, selectUserCountryCode, + selectUser, } from 'redux/selectors/user'; import rewards from 'rewards'; import Lbryio from 'lbryio'; @@ -703,6 +704,21 @@ export function doUserSetReferrer(referrer, shouldClaim) { }; } +export function doUserSetCountry(country) { + return (dispatch, getState) => { + const state = getState(); + const user = selectUser(state); + + Lbryio.call('user_country', 'set', { country }).then(() => { + const newUser = { ...user, country }; + dispatch({ + type: ACTIONS.USER_FETCH_SUCCESS, + data: { user: newUser }, + }); + }); + }; +} + export function doClaimYoutubeChannels() { return dispatch => { dispatch({