Skip to content

Commit

Permalink
Ensure a minimum duration
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed May 4, 2020
1 parent 06300ff commit 4ced5a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
toolbarNavClass
} from '../style/Toolbar';
import { fullscreenProgressClass } from '../style/progress';
import { sleep } from '../utils';
import { GitCredentialsForm } from '../widgets/CredentialsBox';
import { GitPullPushDialog, Operation } from '../widgets/gitPushPull';
import { IGitExtension } from '../tokens';
Expand Down Expand Up @@ -423,7 +424,7 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
this.setState({
suspend: true
});
await this.props.refresh();
await Promise.all([sleep(1000), this.props.refresh()]);
this.setState({
suspend: false
});
Expand Down
10 changes: 10 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,13 @@ export function getFileIconClassName(path: string, selected = false): string {
return selected ? genericFileIconSelectedStyle : genericFileIconStyle;
}
}

/**
* Returns a promise which resolves after a specified duration.
*
* @param ms - duration (in milliseconds)
* @returns a promise
*/
export function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

0 comments on commit 4ced5a8

Please sign in to comment.