Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Add approval controller count state
Browse files Browse the repository at this point in the history
rekmarks committed Nov 11, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5fbcec1 commit 2a49858
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/approval/ApprovalController.ts
Original file line number Diff line number Diff line change
@@ -69,9 +69,6 @@ export class ApprovalController extends BaseController<ApprovalConfig, ApprovalS
this._approvals = new Map();
this._origins = new Map();
this._showApprovalRequest = config.showApprovalRequest;

this.defaultConfig = config;
this.defaultState = defaultState;
this.initialize();
}

@@ -252,7 +249,7 @@ export class ApprovalController extends BaseController<ApprovalConfig, ApprovalS
this.reject(id, rejectionError);
}
this._origins.clear();
this.update(this.defaultState, true);
this.update(defaultState, true);
}

/**
@@ -383,22 +380,22 @@ export class ApprovalController extends BaseController<ApprovalConfig, ApprovalS
if (this._approvals.has(id)) {
this._approvals.delete(id);

const approvalState = this.state[APPROVALS_STORE_KEY];
const approvals = this.state[APPROVALS_STORE_KEY];
const {
origin,
type = NO_TYPE,
} = approvalState[id];
} = approvals[id];

/* istanbul ignore next */
this._origins.get(origin)?.delete(type);
if (this._isEmptyOrigin(origin)) {
this._origins.delete(origin);
}

const newApprovalState = { ...approvalState };
delete newApprovalState[id];
const newApprovals = { ...approvals };
delete newApprovals[id];
this.update({
[APPROVALS_STORE_KEY]: newApprovalState,
[APPROVALS_STORE_KEY]: newApprovals,
[APPROVAL_COUNT_STORE_KEY]: this.state[APPROVAL_COUNT_STORE_KEY] - 1,
}, true);
}

0 comments on commit 2a49858

Please sign in to comment.