fix updates_for
makes redundant calls
#225
Merged
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.
Type of PR (feature, enhancement, bug fix, etc.)
Bug fix
Description
Modify
updates_for
element to verify that a page is required before fetching it.This PR essentially implements the suggestion made in #209, with minor tweaks.
I've done my best to test this new functionality, but I am not a heavy user of
updates_for
and would appreciate if @julianrubisch could sanity check this. Specifically, my concern is that there could be an unexpected interaction with lazily loaded Turbo Frame content?I was concerned that filtering out blocks might cause the index-based element selection to point to the wrong element, but so far, I haven't been able to trip it up. I really don't want to break this functionality.
@andrewerlanger I also removed the previous line 117, which was where we performed the
shouldUpdate
check initially. It seems as though this should no longer be necessary. Is there a good reason to run the check again?I've tested on a simple User model with
enable_updates
, as well asname
andemail
attributes:Seems to work fine when I update either attribute.
Fixes #209
Why should this be added
@andrewerlanger pointed out that we fetch pages from the server before checking if they are used, which is a waste of computing resources and bandwidth.
Checklist