Skip to content

Commit

Permalink
Git - Tweak optimistic update (#165815)
Browse files Browse the repository at this point in the history
Tweak optimistic update
  • Loading branch information
lszomoru authored Nov 8, 2022
1 parent 8f7aec2 commit 57a5507
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,11 @@ export class Repository implements Disposable {

private async _updateModelState(optimisticResourcesGroups?: GitResourceGroups, cancellationToken?: CancellationToken): Promise<void> {
try {
// Optimistically update resource groups
if (optimisticResourcesGroups) {
this._updateResourceGroupsState(optimisticResourcesGroups);
}

const config = workspace.getConfiguration('git');
let sort = config.get<'alphabetically' | 'committerdate'>('branchSortOrder') || 'alphabetically';
if (sort !== 'alphabetically' && sort !== 'committerdate') {
Expand All @@ -2079,13 +2084,10 @@ export class Repository implements Disposable {

this._sourceControl.commitTemplate = commitTemplate;

// Optimistically update the resource states
if (optimisticResourcesGroups) {
this._updateResourceGroupsState(optimisticResourcesGroups);
}

// Update resource states based on status information
// Update resource states based on status data
this._updateResourceGroupsState(await this.getStatus(cancellationToken));

this._onDidChangeStatus.fire();
}
catch (err) {
if (err instanceof CancellationError) {
Expand All @@ -2105,8 +2107,6 @@ export class Repository implements Disposable {

// set count badge
this.setCountBadge();

this._onDidChangeStatus.fire();
}

private async getStatus(cancellationToken?: CancellationToken): Promise<GitResourceGroups> {
Expand Down

0 comments on commit 57a5507

Please sign in to comment.