From f334c07c2958d5c3b07c45081d73b64c05fcb98b Mon Sep 17 00:00:00 2001 From: jessop Date: Wed, 11 Nov 2020 12:56:31 -0800 Subject: [PATCH] pass language to authenticate update api language when setLanguage yarn --- package.json | 2 +- ui/redux/actions/settings.js | 10 ++++++++++ ui/redux/actions/user.js | 2 +- yarn.lock | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 81e68ff4e..dee54825b 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-redux": "lbryio/lbry-redux#70c52e42e8b918e60b8f12b36748e1aef8908c39", - "lbryinc": "lbryio/lbryinc#2a9d04b2efcae0a68b7315bf04632db4a757461c", + "lbryinc": "lbryio/lbryinc#eee2cb730ecec95a1344a755035755b0d4dad5cf", "lint-staged": "^7.0.2", "localforage": "^1.7.1", "lodash-es": "^4.17.14", diff --git a/ui/redux/actions/settings.js b/ui/redux/actions/settings.js index cfe5c3328..d13107288 100644 --- a/ui/redux/actions/settings.js +++ b/ui/redux/actions/settings.js @@ -8,6 +8,7 @@ import { makeSelectClientSetting } from 'redux/selectors/settings'; import { doGetSyncDesktop, doSyncUnsubscribe, doSetSyncLock } from 'redux/actions/sync'; import { doAlertWaitingForSync, doGetAndPopulatePreferences } from 'redux/actions/app'; import { selectPrefsReady } from 'redux/selectors/sync'; +import { Lbryio } from 'lbryinc'; const { DEFAULT_LANGUAGE } = require('config'); const { SDK_SYNC_KEYS } = SHARED_PREFERENCES; @@ -294,6 +295,10 @@ export function doFetchLanguage(language) { export function doSetLanguage(language) { return (dispatch, getState) => { const { settings } = getState(); + const { daemonSettings } = settings; + const { share_usage_data: shareSetting } = daemonSettings; + const isSharingData = shareSetting || IS_WEB; + if (settings.language !== language || (settings.loadedLanguages && !settings.loadedLanguages.includes(language))) { // this should match the behavior/logic in index-web.html fetch('https://lbry.com/i18n/get/lbry-desktop/app-strings/' + language + '.json') @@ -311,6 +316,11 @@ export function doSetLanguage(language) { // set on localStorage so it can be read outside of redux window.localStorage.setItem(SETTINGS.LANGUAGE, language); dispatch(doSetClientSetting(SETTINGS.LANGUAGE, language)); + if (isSharingData) { + Lbryio.call('user', 'language', { + language: language, + }); + } }) .catch(e => { window.localStorage.setItem(SETTINGS.LANGUAGE, DEFAULT_LANGUAGE); diff --git a/ui/redux/actions/user.js b/ui/redux/actions/user.js index 289ada28e..e59f0915d 100644 --- a/ui/redux/actions/user.js +++ b/ui/redux/actions/user.js @@ -102,7 +102,7 @@ export function doAuthenticate( type: ACTIONS.AUTHENTICATION_STARTED, }); - Lbryio.authenticate(DOMAIN) + Lbryio.authenticate(DOMAIN, window.navigator.language.slice(0, 2) || 'en') .then(user => { Lbryio.getAuthToken().then(token => { dispatch({ diff --git a/yarn.lock b/yarn.lock index 739ca8d83..1808b8e42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7419,9 +7419,9 @@ lbry-redux@lbryio/lbry-redux#70c52e42e8b918e60b8f12b36748e1aef8908c39: reselect "^3.0.0" uuid "^8.3.1" -lbryinc@lbryio/lbryinc#2a9d04b2efcae0a68b7315bf04632db4a757461c: +lbryinc@lbryio/lbryinc#57b8625454caf6ff295633819fbcfd213aa83e01: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/2a9d04b2efcae0a68b7315bf04632db4a757461c" + resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/57b8625454caf6ff295633819fbcfd213aa83e01" dependencies: reselect "^3.0.0"