Skip to content

Commit 771e739

Browse files
authored
Disable refresh button while refresh is in progress (#1364)
1 parent 544e89f commit 771e739

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/components/Toolbar.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ export interface IToolbarState {
110110
* Panel tab identifier.
111111
*/
112112
tab: number;
113+
114+
/**
115+
* Boolean indicating whether a refresh is currently in progress.
116+
*/
117+
refreshInProgress: boolean;
113118
}
114119

115120
/**
@@ -126,7 +131,8 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
126131
super(props);
127132
this.state = {
128133
branchMenu: false,
129-
tab: 0
134+
tab: 0,
135+
refreshInProgress: false
130136
};
131137
}
132138

@@ -218,6 +224,7 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
218224
className={toolbarButtonClass}
219225
icon={refreshIcon}
220226
onClick={this._onRefreshClick}
227+
disabled={this.state.refreshInProgress}
221228
title={this.props.trans.__(
222229
'Refresh the repository to detect local and remote changes'
223230
)}
@@ -432,6 +439,9 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
432439
'in-progress',
433440
{ autoClose: false }
434441
);
442+
443+
this.setState({ refreshInProgress: true });
444+
435445
try {
436446
await this.props.model.refresh();
437447

@@ -449,6 +459,8 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
449459
type: 'error',
450460
...showError(error, this.props.trans)
451461
});
462+
} finally {
463+
this.setState({ refreshInProgress: false });
452464
}
453465
};
454466
}

0 commit comments

Comments
 (0)