Remove c+ped UserSettingsStore functions
as they don't seem to be necessary
This commit is contained in:
parent
241d95293e
commit
caca5cc00b
|
@ -57,7 +57,6 @@ var RunModernizrTests = require("./modernizr"); // this side-effects a global
|
||||||
var ReactDOM = require("react-dom");
|
var ReactDOM = require("react-dom");
|
||||||
// Workaround for broken export
|
// Workaround for broken export
|
||||||
import * as counterpart from 'counterpart-riot';
|
import * as counterpart from 'counterpart-riot';
|
||||||
var languageHandler = require("matrix-react-sdk/lib/languageHandler");
|
|
||||||
var sdk = require("matrix-react-sdk");
|
var sdk = require("matrix-react-sdk");
|
||||||
var PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
|
var PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
|
||||||
sdk.loadSkin(require('../component-index'));
|
sdk.loadSkin(require('../component-index'));
|
||||||
|
@ -66,6 +65,8 @@ var UpdateChecker = require("./updater");
|
||||||
var q = require('q');
|
var q = require('q');
|
||||||
var request = require('browser-request');
|
var request = require('browser-request');
|
||||||
import Modal from 'matrix-react-sdk/lib/Modal';
|
import Modal from 'matrix-react-sdk/lib/Modal';
|
||||||
|
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
|
||||||
|
import languageHandler from 'matrix-react-sdk/lib/languageHandler';
|
||||||
|
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
|
|
||||||
|
@ -218,20 +219,6 @@ function getConfig() {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is needed to not load the UserSettingsStore before languages are laoded
|
|
||||||
function getLocalSettings() {
|
|
||||||
const localSettingsString = localStorage.getItem('mx_local_settings') || '{}';
|
|
||||||
return JSON.parse(localSettingsString);
|
|
||||||
}
|
|
||||||
// This is needed to not load the UserSettingsStore before languages are laoded
|
|
||||||
function setLocalSetting(type, value) {
|
|
||||||
const settings = getLocalSettings();
|
|
||||||
settings[type] = value;
|
|
||||||
// FIXME: handle errors
|
|
||||||
localStorage.setItem('mx_local_settings', JSON.stringify(settings));
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLoadCompleted() {
|
function onLoadCompleted() {
|
||||||
// if we did a token login, we're now left with the token, hs and is
|
// if we did a token login, we're now left with the token, hs and is
|
||||||
// url as query params in the url; a little nasty but let's redirect to
|
// url as query params in the url; a little nasty but let's redirect to
|
||||||
|
@ -340,13 +327,8 @@ async function loadApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadLanguage() {
|
async function loadLanguage() {
|
||||||
const _localSettings = getLocalSettings();
|
const lang = UserSettingsStore.getLocalSetting('language', languageHandler.getLanguageFromBrowser());
|
||||||
let languages = [];
|
const languages = languageHandler.getNormalizedLanguageKeys(lang);
|
||||||
if (!_localSettings.hasOwnProperty('language')) {
|
|
||||||
languages = languageHandler.getNormalizedLanguageKeys(languageHandler.getLanguageFromBrowser());
|
|
||||||
} else {
|
|
||||||
languages = languageHandler.getNormalizedLanguageKeys(_localSettings.language);
|
|
||||||
}
|
|
||||||
languageHandler.setLanguage(languages, counterpart);
|
languageHandler.setLanguage(languages, counterpart);
|
||||||
setLocalSetting('language', languages[0]);
|
setLocalSetting('language', languages[0]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue