Preserve pagination on entry updates #1563
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.
Fixes #1562
This is far from a perfect solution to a tricky problem.
On the account page, we are rendering the "Activity View" inside a turbo frame. Within that Turbo frame, we have the pagination controls. By default, clicking a new page will update the query param within the frame by default, which means that when the Transaction drawer is closed (and the page auto-refreshes to reload the list), the page that was changed within the turbo frame is not preserved because the top-level page is not aware of it.
There are two potential solutions I can think of, which I've chosen the 1st for simplicity:
params[:page]
down into the Turbo frame and use a custom URL pagination helper for pagination controls that is aware of the top-level page we're currently on.a. Since editing a transaction/trade/balance affects the entire Account history, we're simply refreshing the page entirely rather than attempting to apply Turbo stream updates to the affected parts (most of the page)
b. If we removed this behavior, the user would not see their most recent edits in the activity list, which I think is less ideal than this page refresh
Keeping the entry lists / pagination params synced while editing in the drawer is something we'll have to address with more precision at a later date, but think this is a decent tradeoff for now to keep things as simple as possible.