Fix reverts of self-canceling and non-current sequences, show effective tag changes on UI #593
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.
This PR depends on this refactoring, so review+merge it first: #594
Example that this fixes is below. I reverted the first and the second change, which resulted only in
tag1being removed becausetag2andtag3were already self-cancelled.The new logic goes as this:
{ tag_change_id => [tag_ids] | nil }.nil- it means a request to revert changes to all tags in thatTagChange, otherwise only revert the specifiedtag_idswithin thatTagChange.{image_id, tag_id, last_change: [change_id, added: boolean]}from the DB. Filter out any change where the first change and the last change to the tag are not equal (i.e. self-cancelling changes). The important nuance here is that we don't need to fetch intermediate tag changes! We only need to know the first and the last change in the sequence to effectively revert it.last_changeis the actual last change that determined the current state of the tag on the image.added/removedtag IDs for the image batch update logicAlso fixes this error when zero tag changes are selected:
