pass language to authenticate

update api language when setLanguage

yarn
This commit is contained in:
jessop 2020-11-11 12:56:31 -08:00 committed by Sean Yesmunt
parent 00fb833c38
commit f334c07c29
4 changed files with 14 additions and 4 deletions

View file

@ -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",

View file

@ -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);

View file

@ -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({

View file

@ -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"