Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add approval controller count state #306

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

rekmarks
Copy link
Member

#304 added the methods. This adds the state. Also properly initializes this controller, which wasn't happening previously. It's clearly not always necessary, but the constructor should always call BaseController.initialize().

@rekmarks rekmarks requested a review from a team as a code owner November 11, 2020 01:32
@rekmarks rekmarks force-pushed the approval-controller-count-state branch from 9de5b4d to 2a49858 Compare November 11, 2020 01:34
Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rekmarks rekmarks merged commit 55cc672 into develop Nov 13, 2020
@rekmarks rekmarks deleted the approval-controller-count-state branch November 13, 2020 16:40
@rekmarks rekmarks mentioned this pull request Nov 13, 2020
@Gudahtt
Copy link
Member

Gudahtt commented Nov 13, 2020

Why is the count needed in state? The count methods should already suffice I'd think. This introduces the possibility that it could get out-of-sync with the underlying list.

[id]: info,
},
[APPROVAL_COUNT_STORE_KEY]: this.state[APPROVAL_COUNT_STORE_KEY] + 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an example of the count getting out of sync, this could happen here if id is already in state. Then this would replace that entry, and falsely inflate the count by 1 per additional call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If consumers respect the interface of the controller and only use its public methods, it is impossible for that to happen (see _validateAddParams).

I decided to add the approval count to the state of this controller in order to make it consumable via our usual state subscription logic.

MajorLift pushed a commit that referenced this pull request Oct 11, 2023
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants