mirror of
https://codeberg.org/emersion/gamja.git
synced 2025-02-16 11:09:46 -05:00
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 });
|
||||
}
|
||||
|
||||
setDialogLoading(promise) {
|
||||
const setLoading = (loading) => {
|
||||
this.setState((state) => {
|
||||
return { dialogData: { ...state.dialogData, loading } };
|
||||
});
|
||||
};
|
||||
|
||||
setLoading(true);
|
||||
promise.finally(() => setLoading(false));
|
||||
}
|
||||
|
||||
handleAuthClick(serverID) {
|
||||
let client = this.clients.get(serverID);
|
||||
this.openDialog("auth", { username: client.nick });
|
||||
|
@ -1408,8 +1419,9 @@ export default class App extends Component {
|
|||
handleAuthSubmit(username, password) {
|
||||
let serverID = State.getActiveServerID(this.state);
|
||||
let client = this.clients.get(serverID);
|
||||
// TODO: show auth status (pending/error) in dialog
|
||||
client.authenticate("PLAIN", { username, password }).then(() => {
|
||||
let promise = client.authenticate("PLAIN", { username, password }).then(() => {
|
||||
this.dismissDialog();
|
||||
|
||||
let firstClient = this.clients.values().next().value;
|
||||
if (client !== firstClient) {
|
||||
return;
|
||||
|
@ -1427,7 +1439,7 @@ export default class App extends Component {
|
|||
};
|
||||
store.autoconnect.put(autoconnect);
|
||||
});
|
||||
this.dismissDialog();
|
||||
this.setDialogLoading(promise);
|
||||
}
|
||||
|
||||
handleRegisterClick(serverID) {
|
||||
|
@ -1436,17 +1448,6 @@ export default class App extends Component {
|
|||
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) {
|
||||
let serverID = State.getActiveServerID(this.state);
|
||||
let client = this.clients.get(serverID);
|
||||
|
@ -1677,9 +1678,16 @@ export default class App extends Component {
|
|||
`;
|
||||
break;
|
||||
case "auth":
|
||||
if (dialogData.loading) {
|
||||
dialogBody = html`<p>Logging in…</p>`;
|
||||
} else {
|
||||
dialogBody = html`
|
||||
<${AuthForm} username=${dialogData.username} onSubmit=${this.handleAuthSubmit}/>
|
||||
`;
|
||||
}
|
||||
dialog = html`
|
||||
<${Dialog} title="Login to ${getServerName(activeServer, activeBouncerNetwork, isBouncer)}" onDismiss=${this.dismissDialog}>
|
||||
<${AuthForm} username=${dialogData.username} onSubmit=${this.handleAuthSubmit}/>
|
||||
${dialogBody}
|
||||
</>
|
||||
`;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue