Login block on initialSync with spinners
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
36fea4d487
commit
346b2e8588
4 changed files with 57 additions and 22 deletions
|
@ -119,6 +119,24 @@ limitations under the License.
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_AuthBody_paddedFooter {
|
||||||
|
height: 80px; // height of the submit button + register link
|
||||||
|
padding-top: 28px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.mx_AuthBody_paddedFooter_title {
|
||||||
|
margin-top: 16px;
|
||||||
|
font-size: $font-15px;
|
||||||
|
line-height: $font-24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_AuthBody_paddedFooter_subtitle {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: $font-10px;
|
||||||
|
line-height: $font-14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.mx_AuthBody_changeFlow {
|
.mx_AuthBody_changeFlow {
|
||||||
display: block;
|
display: block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
|
@ -1906,23 +1906,12 @@ export default createReactClass({
|
||||||
this._onLoggedIn();
|
this._onLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for the master cross-signing key in SSSS as a quick proxy for
|
this.setState({ pendingInitialSync: true });
|
||||||
// whether cross-signing has been set up on the account. We can't
|
await this.firstSyncPromise.promise;
|
||||||
// really continue until we know whether it's there or not so retry
|
|
||||||
// if this fails.
|
|
||||||
let masterKeyInStorage;
|
|
||||||
while (masterKeyInStorage === undefined) {
|
|
||||||
try {
|
|
||||||
masterKeyInStorage = !!await cli.getAccountDataFromServer("m.cross_signing.master");
|
|
||||||
} catch (e) {
|
|
||||||
if (e.errcode === "M_NOT_FOUND") {
|
|
||||||
masterKeyInStorage = false;
|
|
||||||
} else {
|
|
||||||
console.warn("Secret storage account data check failed: retrying...", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Test for the master cross-signing key in SSSS as a quick proxy for
|
||||||
|
// whether cross-signing has been set up on the account.
|
||||||
|
const masterKeyInStorage = !!cli.getAccountData("m.cross_signing.master");
|
||||||
if (masterKeyInStorage) {
|
if (masterKeyInStorage) {
|
||||||
// Auto-enable cross-signing for the new session when key found in
|
// Auto-enable cross-signing for the new session when key found in
|
||||||
// secret storage.
|
// secret storage.
|
||||||
|
@ -1939,6 +1928,7 @@ export default createReactClass({
|
||||||
} else {
|
} else {
|
||||||
this._onLoggedIn();
|
this._onLoggedIn();
|
||||||
}
|
}
|
||||||
|
this.setState({ pendingInitialSync: false });
|
||||||
|
|
||||||
return setLoggedInPromise;
|
return setLoggedInPromise;
|
||||||
},
|
},
|
||||||
|
@ -2060,6 +2050,7 @@ export default createReactClass({
|
||||||
const Login = sdk.getComponent('structures.auth.Login');
|
const Login = sdk.getComponent('structures.auth.Login');
|
||||||
view = (
|
view = (
|
||||||
<Login
|
<Login
|
||||||
|
isSyncing={this.state.pendingInitialSync}
|
||||||
onLoggedIn={this.onUserCompletedLoginFlow}
|
onLoggedIn={this.onUserCompletedLoginFlow}
|
||||||
onRegisterClick={this.onRegisterClick}
|
onRegisterClick={this.onRegisterClick}
|
||||||
fallbackHsUrl={this.getFallbackHsUrl()}
|
fallbackHsUrl={this.getFallbackHsUrl()}
|
||||||
|
|
|
@ -84,11 +84,13 @@ export default createReactClass({
|
||||||
onServerConfigChange: PropTypes.func.isRequired,
|
onServerConfigChange: PropTypes.func.isRequired,
|
||||||
|
|
||||||
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
|
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
|
||||||
|
isSyncing: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
busy: false,
|
busy: false,
|
||||||
|
busyLoggingIn: null,
|
||||||
errorText: null,
|
errorText: null,
|
||||||
loginIncorrect: false,
|
loginIncorrect: false,
|
||||||
canTryLogin: true, // can we attempt to log in or are there validation errors?
|
canTryLogin: true, // can we attempt to log in or are there validation errors?
|
||||||
|
@ -169,6 +171,7 @@ export default createReactClass({
|
||||||
const componentState = AutoDiscoveryUtils.authComponentStateForError(e);
|
const componentState = AutoDiscoveryUtils.authComponentStateForError(e);
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: false,
|
busy: false,
|
||||||
|
busyLoggingIn: false,
|
||||||
...componentState,
|
...componentState,
|
||||||
});
|
});
|
||||||
aliveAgain = !componentState.serverErrorIsFatal;
|
aliveAgain = !componentState.serverErrorIsFatal;
|
||||||
|
@ -182,6 +185,7 @@ export default createReactClass({
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: true,
|
busy: true,
|
||||||
|
busyLoggingIn: true,
|
||||||
errorText: null,
|
errorText: null,
|
||||||
loginIncorrect: false,
|
loginIncorrect: false,
|
||||||
});
|
});
|
||||||
|
@ -250,6 +254,7 @@ export default createReactClass({
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: false,
|
busy: false,
|
||||||
|
busyLoggingIn: false,
|
||||||
errorText: errorText,
|
errorText: errorText,
|
||||||
// 401 would be the sensible status code for 'incorrect password'
|
// 401 would be the sensible status code for 'incorrect password'
|
||||||
// but the login API gives a 403 https://matrix.org/jira/browse/SYN-744
|
// but the login API gives a 403 https://matrix.org/jira/browse/SYN-744
|
||||||
|
@ -594,6 +599,7 @@ export default createReactClass({
|
||||||
loginIncorrect={this.state.loginIncorrect}
|
loginIncorrect={this.state.loginIncorrect}
|
||||||
serverConfig={this.props.serverConfig}
|
serverConfig={this.props.serverConfig}
|
||||||
disableSubmit={this.isBusy()}
|
disableSubmit={this.isBusy()}
|
||||||
|
hideSubmit={this.props.isSyncing || this.state.busyLoggingIn}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -629,9 +635,11 @@ export default createReactClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
const InlineSpinner = sdk.getComponent("elements.InlineSpinner");
|
||||||
const AuthHeader = sdk.getComponent("auth.AuthHeader");
|
const AuthHeader = sdk.getComponent("auth.AuthHeader");
|
||||||
const AuthBody = sdk.getComponent("auth.AuthBody");
|
const AuthBody = sdk.getComponent("auth.AuthBody");
|
||||||
const loader = this.isBusy() ? <div className="mx_Login_loader"><Loader /></div> : null;
|
const loader = this.isBusy() && !this.state.busyLoggingIn ?
|
||||||
|
<div className="mx_Login_loader"><Loader /></div> : null;
|
||||||
|
|
||||||
const errorText = this.state.errorText;
|
const errorText = this.state.errorText;
|
||||||
|
|
||||||
|
@ -658,6 +666,25 @@ export default createReactClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let footer;
|
||||||
|
if (this.props.isSyncing || this.state.busyLoggingIn) {
|
||||||
|
footer = <div className="mx_AuthBody_paddedFooter">
|
||||||
|
<div className="mx_AuthBody_paddedFooter_title">
|
||||||
|
<InlineSpinner w={20} h={20} />
|
||||||
|
{ this.props.isSyncing ? _t("Syncing...") : _t("Signing In...") }
|
||||||
|
</div>
|
||||||
|
{ this.props.isSyncing && <div className="mx_AuthBody_paddedFooter_subtitle">
|
||||||
|
{_t("If you've joined lots of rooms, this might take a while")}
|
||||||
|
</div> }
|
||||||
|
</div>;
|
||||||
|
} else {
|
||||||
|
footer = (
|
||||||
|
<a className="mx_AuthBody_changeFlow" onClick={this.onTryRegisterClick} href="#">
|
||||||
|
{ _t('Create account') }
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthPage>
|
<AuthPage>
|
||||||
<AuthHeader />
|
<AuthHeader />
|
||||||
|
@ -670,9 +697,7 @@ export default createReactClass({
|
||||||
{ serverDeadSection }
|
{ serverDeadSection }
|
||||||
{ this.renderServerComponent() }
|
{ this.renderServerComponent() }
|
||||||
{ this.renderLoginComponentForStep() }
|
{ this.renderLoginComponentForStep() }
|
||||||
<a className="mx_AuthBody_changeFlow" onClick={this.onTryRegisterClick} href="#">
|
{ footer }
|
||||||
{ _t('Create account') }
|
|
||||||
</a>
|
|
||||||
</AuthBody>
|
</AuthBody>
|
||||||
</AuthPage>
|
</AuthPage>
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,6 +43,7 @@ export default class PasswordLogin extends React.Component {
|
||||||
onPasswordChanged: PropTypes.func,
|
onPasswordChanged: PropTypes.func,
|
||||||
loginIncorrect: PropTypes.bool,
|
loginIncorrect: PropTypes.bool,
|
||||||
disableSubmit: PropTypes.bool,
|
disableSubmit: PropTypes.bool,
|
||||||
|
hideSubmit: PropTypes.bool,
|
||||||
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
|
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -332,11 +333,11 @@ export default class PasswordLogin extends React.Component {
|
||||||
disabled={this.props.disableSubmit}
|
disabled={this.props.disableSubmit}
|
||||||
/>
|
/>
|
||||||
{forgotPasswordJsx}
|
{forgotPasswordJsx}
|
||||||
<input className="mx_Login_submit"
|
{ !this.props.hideSubmit && <input className="mx_Login_submit"
|
||||||
type="submit"
|
type="submit"
|
||||||
value={_t('Sign in')}
|
value={_t('Sign in')}
|
||||||
disabled={this.props.disableSubmit}
|
disabled={this.props.disableSubmit}
|
||||||
/>
|
/> }
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue