From b1df6f45570ca3cc4fefdd7cb64a6404f70cdcad Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Sat, 7 May 2022 22:29:58 +0100 Subject: [PATCH 1/2] feat: Add allowCustomHomeservers config option --- config.json | 3 ++- src/app/templates/auth/Auth.jsx | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.json b/config.json index c8a5ea6fb..e7f9eea34 100644 --- a/config.json +++ b/config.json @@ -7,5 +7,6 @@ "kde.org", "matrix.org", "chat.mozilla.org" - ] + ], + "allowCustomHomeservers": true } \ No newline at end of file diff --git a/src/app/templates/auth/Auth.jsx b/src/app/templates/auth/Auth.jsx index 33d2152f9..c4d31c45f 100644 --- a/src/app/templates/auth/Auth.jsx +++ b/src/app/templates/auth/Auth.jsx @@ -93,12 +93,13 @@ function Homeserver({ onChange }) { const result = await (await fetch(configFileUrl, { method: 'GET' })).json(); const selectedHs = result?.defaultHomeserver; const hsList = result?.homeserverList; + const allowCustom = result?.allowCustomHomeservers ?? true; if (!hsList?.length > 0 || selectedHs < 0 || selectedHs >= hsList?.length) { throw new Error(); } - setHs({ selected: hsList[selectedHs], list: hsList }); + setHs({ selected: hsList[selectedHs], list: hsList, allowCustom: allowCustom }); } catch { - setHs({ selected: 'matrix.org', list: ['matrix.org'] }); + setHs({ selected: 'matrix.org', list: ['matrix.org'], allowCustom: true }); } }, []); @@ -113,7 +114,8 @@ function Homeserver({ onChange }) { return ( <>
- + ( From e1147e49dc028a6064e20e0989549ce7a80a0613 Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Mon, 9 May 2022 16:06:56 +0100 Subject: [PATCH 2/2] fix: Do not lock the homeserver input when the selection is changed --- src/app/templates/auth/Auth.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/templates/auth/Auth.jsx b/src/app/templates/auth/Auth.jsx index c4d31c45f..1f76476d2 100644 --- a/src/app/templates/auth/Auth.jsx +++ b/src/app/templates/auth/Auth.jsx @@ -107,7 +107,7 @@ function Homeserver({ onChange }) { const { value } = e.target; setProcess({ isLoading: false }); debounce._(async () => { - setHs({ selected: value.trim(), list: hs.list }); + setHs({ ...hs, selected: value.trim() }); }, 700)(); }; @@ -128,7 +128,7 @@ function Homeserver({ onChange }) { onClick={() => { hideMenu(); hsRef.current.value = hsName; - setHs({ selected: hsName, list: hs.list }); + setHs({ ...hs, selected: hsName }); }} > {hsName}