Updated “Reached End” experience#368
Merged
Merged
Conversation
- Updated currentElementId handling to utilize a ref for better performance and consistency. - Enhanced saveScrollPosition logic to ensure accurate element ID dispatching. - Modified WebView message handling to account for reaching the end of the document, improving user experience during scrolling. - Cleaned up unnecessary state updates related to currentElementId for a more streamlined codebase.
| dispatch(actions.setPosition(elementIdToSave, id)); | ||
| } | ||
| }, [dispatch, id, currentElementId]); | ||
| }, [dispatch, id, currentElementIdRef.current]); |
Collaborator
There was a problem hiding this comment.
Refs don't trigger re-render, so this callback won't trigger when currentElementIdRef changes
| webViewRef.current.postMessage(JSON.stringify(scrollMessage)); | ||
| } | ||
| }, [currentElementId]); | ||
| }, [currentElementIdRef.current]); |
Collaborator
There was a problem hiding this comment.
Same here.
It won't trigger re-render, so this callback won't trigger when currentElementIdRef changes
Collaborator
There was a problem hiding this comment.
Navigation can also come as one of the side-effects here.
| if (elementId && !hasReachedEnd) { | ||
| window.ReactNativeWebView.postMessage("scroll-elementId-" + elementId); | ||
| } | ||
| else if (hasReachedEnd) { |
Collaborator
There was a problem hiding this comment.
Can you fix the code indentation here.
| @@ -59,11 +58,11 @@ const Reader = ({ navigation, route }) => { | |||
| // Save element ID when leaving screen or app goes to background | |||
| const saveScrollPosition = useCallback(() => { | |||
| // Prefer element ID if available, otherwise fall back to currentElementId state | |||
Collaborator
There was a problem hiding this comment.
This state doesn't exist anymore, so the comment can be removed
Gauravjeetsingh
approved these changes
Dec 31, 2025
smanjot27
pushed a commit
to manjotkaur27/sundar-gutka-react
that referenced
this pull request
Mar 28, 2026
* Refactor ReaderScreen to improve scroll position management - Updated currentElementId handling to utilize a ref for better performance and consistency. - Enhanced saveScrollPosition logic to ensure accurate element ID dispatching. - Modified WebView message handling to account for reaching the end of the document, improving user experience during scrolling. - Cleaned up unnecessary state updates related to currentElementId for a more streamlined codebase. * fix: reviews
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Updated “Reached End” experience
When a user reaches the end of a Bani, the next time they open the same Bani it should start from the beginning.
What changed