From 9ae812c346333f4c4b294add6438464c2591904f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 May 2020 15:17:55 -0600 Subject: [PATCH] Add a loading state for email addresses/phone numbers in settings Fixes https://github.com/vector-im/riot-web/issues/13432 --- .../tabs/user/_GeneralUserSettingsTab.scss | 6 +++ .../tabs/user/GeneralUserSettingsTab.js | 39 ++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss b/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss index 62d230e752..95a46b51ee 100644 --- a/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss +++ b/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss @@ -23,6 +23,12 @@ limitations under the License. margin-top: 0; } +.mx_GeneralUserSettingsTab_accountSection .mx_Spinner, +.mx_GeneralUserSettingsTab_discovery .mx_Spinner { + // Move the spinner to the left side of the container (default center) + justify-content: left; +} + .mx_GeneralUserSettingsTab_accountSection .mx_EmailAddresses, .mx_GeneralUserSettingsTab_accountSection .mx_PhoneNumbers, .mx_GeneralUserSettingsTab_discovery .mx_ExistingEmailAddress, diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js index 801062bff4..867982ad2b 100644 --- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js @@ -38,6 +38,7 @@ import {SERVICE_TYPES} from "matrix-js-sdk"; import IdentityAuthClient from "../../../../../IdentityAuthClient"; import {abbreviateUrl} from "../../../../../utils/UrlUtils"; import { getThreepidsWithBindStatus } from '../../../../../boundThreepids'; +import Spinner from "../../../elements/Spinner"; export default class GeneralUserSettingsTab extends React.Component { static propTypes = { @@ -60,6 +61,7 @@ export default class GeneralUserSettingsTab extends React.Component { }, emails: [], msisdns: [], + loading3pids: true, // whether or not the emails and msisdns have been loaded ...this._calculateThemeState(), customThemeUrl: "", customThemeMessage: {isError: false, text: ""}, @@ -158,8 +160,11 @@ export default class GeneralUserSettingsTab extends React.Component { ); console.warn(e); } - this.setState({ emails: threepids.filter((a) => a.medium === 'email') }); - this.setState({ msisdns: threepids.filter((a) => a.medium === 'msisdn') }); + this.setState({ + emails: threepids.filter((a) => a.medium === 'email'), + msisdns: threepids.filter((a) => a.medium === 'msisdn'), + loading3pids: false, + }); } async _checkTerms() { @@ -325,7 +330,6 @@ export default class GeneralUserSettingsTab extends React.Component { const ChangePassword = sdk.getComponent("views.settings.ChangePassword"); const EmailAddresses = sdk.getComponent("views.settings.account.EmailAddresses"); const PhoneNumbers = sdk.getComponent("views.settings.account.PhoneNumbers"); - const Spinner = sdk.getComponent("views.elements.Spinner"); let passwordChangeForm = ( - {_t("Email addresses")} - + : - - {_t("Phone numbers")} - ; + const msisdns = this.state.loading3pids + ? + : + />; + threepidSection =
+ {_t("Email addresses")} + {emails} + + {_t("Phone numbers")} + {msisdns}
; } else if (this.state.serverSupportsSeparateAddAndBind === null) { threepidSection = ; @@ -491,12 +501,15 @@ export default class GeneralUserSettingsTab extends React.Component { const EmailAddresses = sdk.getComponent("views.settings.discovery.EmailAddresses"); const PhoneNumbers = sdk.getComponent("views.settings.discovery.PhoneNumbers"); + const emails = this.state.loading3pids ? : ; + const msisdns = this.state.loading3pids ? : ; + const threepidSection = this.state.haveIdServer ?
{_t("Email addresses")} - + {emails} {_t("Phone numbers")} - + {msisdns}
: null; return (