From 7ae86af7df628ca97497a4527f6bf1d76d12f999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 28 Nov 2020 19:36:18 +0100 Subject: [PATCH 01/12] Added loadSpellCheckLanguages() method --- src/vector/init.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vector/init.tsx b/src/vector/init.tsx index f625644d04..28f06fb3db 100644 --- a/src/vector/init.tsx +++ b/src/vector/init.tsx @@ -115,6 +115,16 @@ export async function loadLanguage() { } } +export async function loadSpellCheckLanguages() { + const langs = SettingsStore.getValue("spell-check-languages", null, /*excludeDefault=*/true); + + try { + await languageHandler.setSpellCheckLanguage(langs); + } catch (e) { + console.error("Unable to set spell-check language", e); + } +} + export async function loadSkin() { // Ensure the skin is the very first thing to load for the react-sdk. We don't even want to reference // the SDK until we have to in imports. From 13a5192995b6fd90ec3cd3a022372e7299db5dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 28 Nov 2020 19:36:39 +0100 Subject: [PATCH 02/12] Added a call to loadSpellCheckLanguages() method --- src/vector/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vector/index.ts b/src/vector/index.ts index a88c1d068d..be7a0824b0 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -95,6 +95,7 @@ async function start() { loadConfig, loadSkin, loadLanguage, + loadSpellCheckLanguages, loadTheme, loadApp, showError, @@ -138,12 +139,13 @@ async function start() { // Load language after loading config.json so that settingsDefaults.language can be applied const loadLanguagePromise = loadLanguage(); + const loadSpellCheckLanguagesPromise = loadSpellCheckLanguages(); // as quickly as we possibly can, set a default theme... const loadThemePromise = loadTheme(); const loadSkinPromise = loadSkin(); // await things settling so that any errors we have to render have features like i18n running - await settled(loadSkinPromise, loadThemePromise, loadLanguagePromise); + await settled(loadSkinPromise, loadThemePromise, loadLanguagePromise, loadSpellCheckLanguagesPromise); let acceptBrowser = supportedBrowser; if (!acceptBrowser && window.localStorage) { @@ -194,6 +196,7 @@ async function start() { await loadSkinPromise; await loadThemePromise; await loadLanguagePromise; + await loadSpellCheckLanguagesPromise; // Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to // run on the components. From 3419140beec397d3d9d8944ed2554e5797993412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 28 Nov 2020 19:38:39 +0100 Subject: [PATCH 03/12] Fix spelling --- src/vector/init.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/init.tsx b/src/vector/init.tsx index 28f06fb3db..b3c20b69ec 100644 --- a/src/vector/init.tsx +++ b/src/vector/init.tsx @@ -119,7 +119,7 @@ export async function loadSpellCheckLanguages() { const langs = SettingsStore.getValue("spell-check-languages", null, /*excludeDefault=*/true); try { - await languageHandler.setSpellCheckLanguage(langs); + await languageHandler.setSpellCheckLanguages(langs); } catch (e) { console.error("Unable to set spell-check language", e); } From a8a422105b3f7294753692d15f1a0bc3aa82bbaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 29 Nov 2020 20:52:19 +0100 Subject: [PATCH 04/12] Added getAvailableSpellCheckLanguages() method --- src/vector/platform/ElectronPlatform.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 48fce17150..b14c0cfa98 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -496,6 +496,10 @@ export default class ElectronPlatform extends VectorBasePlatform { }); } + async getAvailableSpellCheckLanguages(): Promise { + return this._ipcCall('getAvailableSpellCheckLanguages'); + } + getSSOCallbackUrl(fragmentAfterLogin: string): URL { const url = super.getSSOCallbackUrl(fragmentAfterLogin); url.protocol = "element"; From 1c9d25986ad60ccf8df7aba7df371d0a08178b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 1 Dec 2020 20:19:14 +0100 Subject: [PATCH 05/12] Cleanup --- src/vector/platform/ElectronPlatform.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index b14c0cfa98..0dd57ef45f 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -489,9 +489,9 @@ export default class ElectronPlatform extends VectorBasePlatform { return this.eventIndexManager; } - setLanguage(preferredLangs: string[]) { - this._ipcCall('setLanguage', preferredLangs).catch(error => { - console.log("Failed to send setLanguage IPC to Electron"); + setSpellCheckLanguages(preferredLangs: string[]) { + this._ipcCall('setSpellCheckLanguages', preferredLangs).catch(error => { + console.log("Failed to send setSpellCheckLanguages IPC to Electron"); console.error(error); }); } From 6844c8f92e9678827e3727b7051efdf8abeab41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 2 Dec 2020 20:15:00 +0100 Subject: [PATCH 06/12] Hide spell-check settings if not using Electron --- src/vector/platform/ElectronPlatform.tsx | 8 ++++++++ src/vector/platform/WebPlatform.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 0dd57ef45f..10b72d63d1 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -324,6 +324,14 @@ export default class ElectronPlatform extends VectorBasePlatform { return 'Electron Platform'; // no translation required: only used for analytics } + /** + * Return true if platform supports multi-language + * spell-checking, otherwise false. + */ + supportsMultiLanguageSpellCheck(): boolean { + return true; + } + setNotificationCount(count: number) { if (this.notificationCount === count) return; super.setNotificationCount(count); diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index 2e739a2660..c2f3743609 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -38,6 +38,14 @@ export default class WebPlatform extends VectorBasePlatform { return 'Web Platform'; // no translation required: only used for analytics } + /** + * Return true if platform supports multi-language + * spell-checking, otherwise false. + */ + supportsMultiLanguageSpellCheck(): boolean { + return false; + } + /** * Returns true if the platform supports displaying * notifications, otherwise false. From ccc30387935468a1c9133a6266874b2162646fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 3 Dec 2020 08:27:18 +0100 Subject: [PATCH 07/12] Don't exclude default --- src/vector/init.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/init.tsx b/src/vector/init.tsx index b3c20b69ec..360449cf58 100644 --- a/src/vector/init.tsx +++ b/src/vector/init.tsx @@ -116,7 +116,7 @@ export async function loadLanguage() { } export async function loadSpellCheckLanguages() { - const langs = SettingsStore.getValue("spell-check-languages", null, /*excludeDefault=*/true); + const langs = SettingsStore.getValue("spell-check-languages", null, false); try { await languageHandler.setSpellCheckLanguages(langs); From 5f15ee4ea579d99235c5f4fad3a1760f716650fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 18 Feb 2021 19:05:40 +0100 Subject: [PATCH 08/12] Mark macOS as false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/vector/platform/ElectronPlatform.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index c80d926d2e..61df849754 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -328,6 +328,7 @@ export default class ElectronPlatform extends VectorBasePlatform { * spell-checking, otherwise false. */ supportsMultiLanguageSpellCheck(): boolean { + if (isMac) return false; return true; } From 4961037dbe0bac9a1939125118929d2d04753edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 18 Feb 2021 19:16:33 +0100 Subject: [PATCH 09/12] Remove setting languages on startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/vector/index.ts | 5 +---- src/vector/init.tsx | 10 ---------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/vector/index.ts b/src/vector/index.ts index 26414020db..b3e29bc382 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -91,7 +91,6 @@ async function start() { loadConfig, loadSkin, loadLanguage, - loadSpellCheckLanguages, loadTheme, loadApp, showError, @@ -135,13 +134,12 @@ async function start() { // Load language after loading config.json so that settingsDefaults.language can be applied const loadLanguagePromise = loadLanguage(); - const loadSpellCheckLanguagesPromise = loadSpellCheckLanguages(); // as quickly as we possibly can, set a default theme... const loadThemePromise = loadTheme(); const loadSkinPromise = loadSkin(); // await things settling so that any errors we have to render have features like i18n running - await settled(loadSkinPromise, loadThemePromise, loadLanguagePromise, loadSpellCheckLanguagesPromise); + await settled(loadSkinPromise, loadThemePromise, loadLanguagePromise); let acceptBrowser = supportedBrowser; if (!acceptBrowser && window.localStorage) { @@ -192,7 +190,6 @@ async function start() { await loadSkinPromise; await loadThemePromise; await loadLanguagePromise; - await loadSpellCheckLanguagesPromise; // Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to // run on the components. diff --git a/src/vector/init.tsx b/src/vector/init.tsx index 94effdaed2..de022622db 100644 --- a/src/vector/init.tsx +++ b/src/vector/init.tsx @@ -115,16 +115,6 @@ export async function loadLanguage() { } } -export async function loadSpellCheckLanguages() { - const langs = SettingsStore.getValue("spell-check-languages", null, false); - - try { - await languageHandler.setSpellCheckLanguages(langs); - } catch (e) { - console.error("Unable to set spell-check language", e); - } -} - export async function loadSkin() { // Ensure the skin is the very first thing to load for the react-sdk. We don't even want to reference // the SDK until we have to in imports. From 8cf2ab436d5490a538ae399d60fdd020e1d044c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 18 Feb 2021 20:12:51 +0100 Subject: [PATCH 10/12] Use getSpellCheckLanguages() instead of a setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/vector/platform/ElectronPlatform.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 61df849754..9453982f3c 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -504,6 +504,10 @@ export default class ElectronPlatform extends VectorBasePlatform { }); } + async getSpellCheckLanguages(): Promise { + return this._ipcCall('getSpellCheckLanguages'); + } + async getAvailableSpellCheckLanguages(): Promise { return this._ipcCall('getAvailableSpellCheckLanguages'); } From 0f7a42258c7b90a8dc5f2d3be47238013a436784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 2 Mar 2021 14:53:04 +0100 Subject: [PATCH 11/12] Add a comment Co-authored-by: J. Ryan Stinnett --- src/vector/platform/ElectronPlatform.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 9453982f3c..ab45fd7d97 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -328,6 +328,7 @@ export default class ElectronPlatform extends VectorBasePlatform { * spell-checking, otherwise false. */ supportsMultiLanguageSpellCheck(): boolean { + // Electron uses OS spell checking on macOS, so no need for in-app options if (isMac) return false; return true; } From c745991a9a93682d9e12f5bcac68561f43a3ef6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 2 Mar 2021 14:58:40 +0100 Subject: [PATCH 12/12] Remove duplicate supportsMultiLanguageSpellCheck() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/vector/platform/WebPlatform.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index aaa6ff4eba..9f9f4a3995 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -46,14 +46,6 @@ export default class WebPlatform extends VectorBasePlatform { return 'Web Platform'; // no translation required: only used for analytics } - /** - * Return true if platform supports multi-language - * spell-checking, otherwise false. - */ - supportsMultiLanguageSpellCheck(): boolean { - return false; - } - /** * Returns true if the platform supports displaying * notifications, otherwise false.