-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fixes person navigation after image upload #9076
Merged
charlesBochet
merged 2 commits into
twentyhq:main
from
mdrazak2001:fix/person-navigation
Dec 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
this does not feels right to me, we need to retrieve the previous (resp. next) record based on the viewFilters and sort. We cannot remove the filter as you are doing.
Could you explain your change and how you think it's fixing the issue?
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.
Hi @charlesBochet,
Thanks for the feedback! You're right—replacing
filter
entirely was incorrect. I've updated the code to combine the originalfilter
with{ id: { neq: objectRecordId } }
to ensure we respect view filters and sorting while excluding the current record (to prevent duplicate pagination results).Let me know if this works!
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.
I'm a bit confused because to me this should not be tied to filters.
It should be tied to cursor / pagination logic. To get the next record for example, we do:
This should already get the next item without having to change the filters. Why isn't this working?
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 did some logging to understand the behavior further. Here’s what I observed:
These responses were returned by
useFindManyRecords
. It seems that after the image upload, the Records After array includes both the current record and the next record. As a result, when the "Next" button is pressed, it navigates to the current person instead of the expected next person.This behavior suggests that while the cursor logic retrieves records after the current position, the filtering isn't excluding the current record
Explicitly adding a filter like
{ id: { neq: currentRecordId } }
ensures the current record is excluded, preventing this duplication and aligning the navigation behavior with expectations.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.
Okay, I think this is an optimistic rendering issue. What's likely happening is that on record update (useUpdateOneRecord) we are triggering optimistic effects triggerUpdateRecordOptimisticEffect.
This Optimistic effects (through cache.modify) is checking if the updated record match the query and if yes it adds it.
However this logic does not take the cursor into account : it's not because it matches the filter that the record should be added to the query result, it should also check that if we have orderBy + cursor + limit, it should be added.
This is not a big change but might be a bit tricky to implement.
Now I understand your change and even if not completely right it might solve the issue for now
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.
And I think it works
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.
Thank you @charlesBochet for the detailed explanation, am able to connect the dots now!