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.
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
Fix duplicating annotations via toggling show archived annotations button and fix downsample modal rendering errors #6058
Fix duplicating annotations via toggling show archived annotations button and fix downsample modal rendering errors #6058
Changes from 3 commits
3e28707
282cde8
2f5efe7
240ab69
9cec3f5
29f9837
02b7419
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.
The problem here was that the
fetchNextPage
relies onthis.state.shouldShowArchivedTracings
being up to date, but the setState Update of line 102 is not executed before thefetchNextPage
is called. This lead to one of the errors. -> When wanting to initially show the archived annotations, the view instead showed the default (the active annotations).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.
Cool that you found the issue 👍 However, I think, that there is another race condition looming:
fetchNextPage
itself fetches annotations (depending onthis.state.shouldShowArchivedTracings
) and then callssetModeState
which itself reads again fromthis.state.shouldShowArchivedTracings
. If the user toggles the state after the annotations-fetch has started but before it finished, the annotations will be pushed into the wrong array. I think, it would make sense to adaptsetModeState
to accept theshouldShowArchivedTracings
parameter directly (instead of reading it out again). Do you agree?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.
Jep 👍 , that sounds like a reasonable approach to fix this.
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
performedInitialFetch
is needed to enforce the initial fetch, as otherwise the initial fetch would not be executed when the active annotations should be shown initially. Reason: Because the default value forshouldShowArchivedTracings
is false leading to the whole if to be true.performedInitialFetch
simply enforces the initial fetch. I did not take the option makeshouldShowArchivedTracings
initially null, becauseperformedInitialFetch
seemed easier to understand later on to me.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.
Hmm, it's still a bit unusual, I guess, since
componentDidUpdate
is not called on the initial render (that's whatcomponentDidMount
is for). So, you are relying on the component updating, anyway, so that the fetch can be done. Probably this happens most of the time because ofthis.setState(persistence.load(this.props.history));
, but it's not really safe. For example, if the localStorage is empty, the persistence module probably doesn't load anything so the state wouldn't change then?I think, I would prefer to use this in
componentDidMount
:The callback is triggered after
setState
is done. Then, you also don't needperformedInitialFetch
if I'm not mistaken.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.
Oh yeah, you are totally right here 👍. That's a nice suggestion. Thanks 🚀.
👍
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 problem was that this method did not depend on the state of the annotation but on the "show archived buttons" state. This way it is saver, that the correct actions are shown
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.
@philippotto Do you know of any other states an annotation can be in?
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.
If I'm interpreting
webknossos/tools/postgres/schema.sql
Line 29 in 6c6a23b
string
type in api_flow_types.js to"ACTIVE" | "Finished" | ...
(depending on what @fm3 replied).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.
Explorative annotations exposed to the front-end can currently only be Active or Finished