mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
add a spinner while we upload new user avatar on EditProfile
This commit is contained in:
parent
6fbe060973
commit
781567f0df
1 changed files with 18 additions and 5 deletions
|
@ -20,6 +20,7 @@ import { PillDivider } from './session/PillDivider';
|
||||||
import { ToastUtils, UserUtils } from '../session/utils';
|
import { ToastUtils, UserUtils } from '../session/utils';
|
||||||
import { DefaultTheme } from 'styled-components';
|
import { DefaultTheme } from 'styled-components';
|
||||||
import { MAX_USERNAME_LENGTH } from './session/registration/RegistrationTabs';
|
import { MAX_USERNAME_LENGTH } from './session/registration/RegistrationTabs';
|
||||||
|
import { SessionSpinner } from './session/SessionSpinner';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
i18n: any;
|
i18n: any;
|
||||||
|
@ -36,6 +37,7 @@ interface State {
|
||||||
setProfileName: string;
|
setProfileName: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
mode: 'default' | 'edit' | 'qr';
|
mode: 'default' | 'edit' | 'qr';
|
||||||
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EditProfileDialog extends React.Component<Props, State> {
|
export class EditProfileDialog extends React.Component<Props, State> {
|
||||||
|
@ -56,6 +58,7 @@ export class EditProfileDialog extends React.Component<Props, State> {
|
||||||
setProfileName: this.props.profileName,
|
setProfileName: this.props.profileName,
|
||||||
avatar: this.props.avatarPath,
|
avatar: this.props.avatarPath,
|
||||||
mode: 'default',
|
mode: 'default',
|
||||||
|
loading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.inputEl = React.createRef();
|
this.inputEl = React.createRef();
|
||||||
|
@ -111,6 +114,7 @@ export class EditProfileDialog extends React.Component<Props, State> {
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="spacer-lg" />
|
<div className="spacer-lg" />
|
||||||
|
<SessionSpinner loading={this.state.loading} />
|
||||||
|
|
||||||
{viewDefault || viewQR ? (
|
{viewDefault || viewQR ? (
|
||||||
<SessionButton
|
<SessionButton
|
||||||
|
@ -127,6 +131,7 @@ export class EditProfileDialog extends React.Component<Props, State> {
|
||||||
buttonType={SessionButtonType.BrandOutline}
|
buttonType={SessionButtonType.BrandOutline}
|
||||||
buttonColor={SessionButtonColor.Green}
|
buttonColor={SessionButtonColor.Green}
|
||||||
onClick={this.onClickOK}
|
onClick={this.onClickOK}
|
||||||
|
disabled={this.state.loading}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -305,12 +310,20 @@ export class EditProfileDialog extends React.Component<Props, State> {
|
||||||
? this.inputEl.current.files[0]
|
? this.inputEl.current.files[0]
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
this.props.onOk(newName, avatar);
|
this.setState(
|
||||||
|
{
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
await this.props.onOk(newName, avatar);
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
|
||||||
this.setState({
|
mode: 'default',
|
||||||
mode: 'default',
|
setProfileName: this.state.profileName,
|
||||||
setProfileName: this.state.profileName,
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private closeDialog() {
|
private closeDialog() {
|
||||||
|
|
Loading…
Reference in a new issue