Mark auth dialog as loading
This commit is contained in:
parent
47f56f06b9
commit
a1ff1be342
1 changed files with 23 additions and 15 deletions
|
@ -1400,6 +1400,17 @@ export default class App extends Component {
|
||||||
this.setState({ dialog: null, dialogData: null });
|
this.setState({ dialog: null, dialogData: null });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDialogLoading(promise) {
|
||||||
|
const setLoading = (loading) => {
|
||||||
|
this.setState((state) => {
|
||||||
|
return { dialogData: { ...state.dialogData, loading } };
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
promise.finally(() => setLoading(false));
|
||||||
|
}
|
||||||
|
|
||||||
handleAuthClick(serverID) {
|
handleAuthClick(serverID) {
|
||||||
let client = this.clients.get(serverID);
|
let client = this.clients.get(serverID);
|
||||||
this.openDialog("auth", { username: client.nick });
|
this.openDialog("auth", { username: client.nick });
|
||||||
|
@ -1408,8 +1419,9 @@ export default class App extends Component {
|
||||||
handleAuthSubmit(username, password) {
|
handleAuthSubmit(username, password) {
|
||||||
let serverID = State.getActiveServerID(this.state);
|
let serverID = State.getActiveServerID(this.state);
|
||||||
let client = this.clients.get(serverID);
|
let client = this.clients.get(serverID);
|
||||||
// TODO: show auth status (pending/error) in dialog
|
let promise = client.authenticate("PLAIN", { username, password }).then(() => {
|
||||||
client.authenticate("PLAIN", { username, password }).then(() => {
|
this.dismissDialog();
|
||||||
|
|
||||||
let firstClient = this.clients.values().next().value;
|
let firstClient = this.clients.values().next().value;
|
||||||
if (client !== firstClient) {
|
if (client !== firstClient) {
|
||||||
return;
|
return;
|
||||||
|
@ -1427,7 +1439,7 @@ export default class App extends Component {
|
||||||
};
|
};
|
||||||
store.autoconnect.put(autoconnect);
|
store.autoconnect.put(autoconnect);
|
||||||
});
|
});
|
||||||
this.dismissDialog();
|
this.setDialogLoading(promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRegisterClick(serverID) {
|
handleRegisterClick(serverID) {
|
||||||
|
@ -1436,17 +1448,6 @@ export default class App extends Component {
|
||||||
this.openDialog("register", { emailRequired });
|
this.openDialog("register", { emailRequired });
|
||||||
}
|
}
|
||||||
|
|
||||||
setDialogLoading(promise) {
|
|
||||||
const setLoading = (loading) => {
|
|
||||||
this.setState((state) => {
|
|
||||||
return { dialogData: { ...state.dialogData, loading } };
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
setLoading(true);
|
|
||||||
promise.finally(() => setLoading(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
handleRegisterSubmit(email, password) {
|
handleRegisterSubmit(email, password) {
|
||||||
let serverID = State.getActiveServerID(this.state);
|
let serverID = State.getActiveServerID(this.state);
|
||||||
let client = this.clients.get(serverID);
|
let client = this.clients.get(serverID);
|
||||||
|
@ -1677,9 +1678,16 @@ export default class App extends Component {
|
||||||
`;
|
`;
|
||||||
break;
|
break;
|
||||||
case "auth":
|
case "auth":
|
||||||
|
if (dialogData.loading) {
|
||||||
|
dialogBody = html`<p>Logging in…</p>`;
|
||||||
|
} else {
|
||||||
|
dialogBody = html`
|
||||||
|
<${AuthForm} username=${dialogData.username} onSubmit=${this.handleAuthSubmit}/>
|
||||||
|
`;
|
||||||
|
}
|
||||||
dialog = html`
|
dialog = html`
|
||||||
<${Dialog} title="Login to ${getServerName(activeServer, activeBouncerNetwork, isBouncer)}" onDismiss=${this.dismissDialog}>
|
<${Dialog} title="Login to ${getServerName(activeServer, activeBouncerNetwork, isBouncer)}" onDismiss=${this.dismissDialog}>
|
||||||
<${AuthForm} username=${dialogData.username} onSubmit=${this.handleAuthSubmit}/>
|
${dialogBody}
|
||||||
</>
|
</>
|
||||||
`;
|
`;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue