From 2ebc1252cbbfc9731dc412947287ef5e4c9ce460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 18 Feb 2021 19:54:54 +0100 Subject: [PATCH] Removed unnecessary functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .../elements/SpellCheckLanguagesDropdown.tsx | 37 ++++++++++--------- .../tabs/user/GeneralUserSettingsTab.js | 6 ++- src/languageHandler.tsx | 14 ------- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/components/views/elements/SpellCheckLanguagesDropdown.tsx b/src/components/views/elements/SpellCheckLanguagesDropdown.tsx index 029d162573..c647f6e410 100644 --- a/src/components/views/elements/SpellCheckLanguagesDropdown.tsx +++ b/src/components/views/elements/SpellCheckLanguagesDropdown.tsx @@ -18,7 +18,7 @@ import React from 'react'; import Dropdown from "../../views/elements/Dropdown" import * as sdk from '../../../index'; -import * as languageHandler from '../../../languageHandler'; +import PlatformPeg from "../../../PlatformPeg"; import SettingsStore from "../../../settings/SettingsStore"; import { _t } from "../../../languageHandler"; @@ -52,23 +52,26 @@ export default class SpellCheckLanguagesDropdown extends React.Component { - languages.sort(function(a, b) { - if (a < b) return -1; - if (a > b) return 1; - return 0; - }); - const langs = []; - languages.forEach((language) => { - langs.push({ - label: language, - value: language, + const plaf = PlatformPeg.get(); + if (plaf) { + plaf.getAvailableSpellCheckLanguages().then((languages) => { + languages.sort(function(a, b) { + if (a < b) return -1; + if (a > b) return 1; + return 0; + }); + const langs = []; + languages.forEach((language) => { + langs.push({ + label: language, + value: language, + }) }) - }) - this.setState({languages: langs}); - }).catch((e) => { - this.setState({languages: ['en']}); - }); + this.setState({languages: langs}); + }).catch((e) => { + this.setState({languages: ['en']}); + }); + } } _onSearchChange(search) { diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js index febbcc8e36..e87dca88c8 100644 --- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js @@ -188,7 +188,10 @@ export default class GeneralUserSettingsTab extends React.Component { SettingsStore.setValue("spell-check-languages", null, SettingLevel.DEVICE, languages); this.setState({spellCheckLanguages: languages}); - languageHandler.setSpellCheckLanguages(languages); + const plaf = PlatformPeg.get(); + if (plaf) { + plaf.setSpellCheckLanguages(languages); + } }; _onPasswordChangeError = (err) => { @@ -402,6 +405,7 @@ export default class GeneralUserSettingsTab extends React.Component { render() { const plaf = PlatformPeg.get(); const supportsMultiLanguageSpellCheck = plaf.supportsMultiLanguageSpellCheck(); + console.log("LOG", supportsMultiLanguageSpellCheck); const discoWarning = this.state.requiredPolicyInfo.hasTerms ? { - const plaf = PlatformPeg.get(); - if (plaf) { - return plaf.getAvailableSpellCheckLanguages(); - } -} - export function getAllLanguagesFromJson() { return getLangsJson().then((langsObject) => { const langs = [];