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.
Star Problems Extension && All Problems Category #188
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
Star Problems Extension && All Problems Category #188
Changes from 6 commits
8d5d6d6
8c7e53e
413564c
42b0856
95dea19
885cac7
a11f371
ed4b40c
62b9c5c
7480bc6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we separate
allProblems
withtreeData
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allProblems
is an id-IProblem dictionary primarily for fast lookup, whose structure is not compatible withtreeData
;allProblems
serves as a buffer which holds all the problems' ownership, where elements intreeData
is just references to the problems;this.onDidChangeTreeDataEvent.fire(problem)
review below, we may need another lookup dictionary for fast retrieving relative nodes.allProblems
seems more similar to it rather thantreeData
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now
allProblems
is decoupled withtreeData
, and will be grouped withallTreeNodes
as an object pool in next PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that the reason that explorer returns to uncollapsed state is that, we do not pass the node element into
this.onDidChangeTreeDataEvent.fire()
(This API can accept a node element. Then all the data are cleared before the explorer rerendering.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some investigations I seems to get the hang of this API. Maybe we can keep another reference container here:
Then, in
updateProblem
function, we can fire events to request all relative nodes to be updated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vigilans Cool. Noticed that now the same problem in the different category has different id. So if we refresh the
Two Sum
inAll Problem
, will theTwo Sum
inDifficulty
be refreshed?That means, I'm thinking that if we should make the same problem has the same id in the whole explorer. Not sure the real behavior of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After further investigations, to accomplish this feature, there are some important changes which I think should be discussed in next PR. In this PR, we may temporarily accept the current behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
updateProblem()
is not used in this PR, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious about the
♥
appearance on different OS platforms, haha.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name her is confusing. Cuz we only handle
isFavorite
here, but the method name looks like we can update all the fields.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we might handle the case of updating other
treeData
fields the at a later time. Seems a overdesign here?Should I leave a comment announcing
modification of other categories is not needed yet
here, or just change the method name?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure now other fields will be updated here in the near PRs, e.g. when a problem is accepted, there will be some code here to update other fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we directly compare
p.id
withproblem.id
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problems are originally in number-ascending order, thus the comparation in index searching should also be done this way.
e.g. the favorite problems' ids are ["1", "4", "16", "23"], I want to delete the problem with id "23" and id is compared directly. Since "4" >= "23" === true, the search process stops at "4", thus the deletion is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the main problem here is that we store the Favorite problems as an array instead of a Map(id -> Problem).
So you may observe that we have to use
findIndex
andsplice
to add/remove items, which I think is hard to read.Can we change it to a Map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it can be discussed in subsequent PRs, when updating
treeData[Category.Company/Tag]
field is necessary(delete problem from treeview after it is solved)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, can be solved in another PR.