Adding a new Review doesn't update the Tree Control Node.#6258
Merged
Conversation
hediet
reviewed
Oct 2, 2024
Comment on lines
+38
to
+48
| for (const repo of folderManager.gitHubRepositories) { | ||
| const pr = repo.pullRequestModels.get(query.prNumber); | ||
| if (pr && pr.reviewThreadsCache.some(c => c.path === query.fileName)) { | ||
| return { | ||
| propagate: false, | ||
| tooltip: 'Commented', | ||
| // allow-any-unicode-next-line | ||
| badge: '💬', | ||
| }; | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
The return does not seem to depend on repo or pr, thus I'd do it like this to simplify the code a bit:
Suggested change
| for (const repo of folderManager.gitHubRepositories) { | |
| const pr = repo.pullRequestModels.get(query.prNumber); | |
| if (pr && pr.reviewThreadsCache.some(c => c.path === query.fileName)) { | |
| return { | |
| propagate: false, | |
| tooltip: 'Commented', | |
| // allow-any-unicode-next-line | |
| badge: '💬', | |
| }; | |
| } | |
| } | |
| const isCommented = folderManager.gitHubRepositories.some(repo => { | |
| const pr = repo.pullRequestModels.get(query.prNumber); | |
| return pr && pr.reviewThreadsCache.some(c => c.path === query.fileName); | |
| }) | |
| if (isCommented) { | |
| return { | |
| propagate: false, | |
| tooltip: 'Commented', | |
| // allow-any-unicode-next-line | |
| badge: '💬', | |
| }; | |
| } |
This reduces nesting a bit and makes the control flow and data flow easier to understand (control flow, because mentally for a for, we have to iterate through the loop to understand how the return works, but for some, we don't care about execution order; data flow because we see immediately that the return does not depend on previous for iterations/repo or pr).
The const isCommented also separates the computation of if it is commented from the result presentation (setting tooltip/badge/etc).
hediet
previously approved these changes
Oct 2, 2024
Tyriar
approved these changes
Oct 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6251