Skip to content

Commit

Permalink
Disable refresh button while refresh is in progress (#1364)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney authored Oct 24, 2024
1 parent 544e89f commit 771e739
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ export interface IToolbarState {
* Panel tab identifier.
*/
tab: number;

/**
* Boolean indicating whether a refresh is currently in progress.
*/
refreshInProgress: boolean;
}

/**
Expand All @@ -126,7 +131,8 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
super(props);
this.state = {
branchMenu: false,
tab: 0
tab: 0,
refreshInProgress: false
};
}

Expand Down Expand Up @@ -218,6 +224,7 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
className={toolbarButtonClass}
icon={refreshIcon}
onClick={this._onRefreshClick}
disabled={this.state.refreshInProgress}
title={this.props.trans.__(
'Refresh the repository to detect local and remote changes'
)}
Expand Down Expand Up @@ -432,6 +439,9 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
'in-progress',
{ autoClose: false }
);

this.setState({ refreshInProgress: true });

try {
await this.props.model.refresh();

Expand All @@ -449,6 +459,8 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
type: 'error',
...showError(error, this.props.trans)
});
} finally {
this.setState({ refreshInProgress: false });
}
};
}

0 comments on commit 771e739

Please sign in to comment.