Fix swipe to see more bug and repository improvements#96
Fix swipe to see more bug and repository improvements#96JesseScott wants to merge 3 commits intomainfrom
Conversation
…itory
Summary of changes:
- Fixed JDK 21 compatibility for Kapt by adding necessary --add-opens to org.gradle.jvmargs in gradle.properties.
- Added hasSwiped property to UserPreferences model.
- Improved UserPreferencesRepository:
- Removed redundant and likely problematic .toPreferences() call in fetchInitialPreferences.
- Included hasSwiped in fetchInitialPreferences.
- Changed hasSwiped Flow to use a custom getter to ensure it always references the current dataStore.data.
- Fixed MainActivity.kt snackbar logic:
- Removed nested coroutine launch within LaunchedEffect to allow proper cancellation of the 5-second delay when hasSwiped changes to true.
- Enhanced UserPreferencesRepositoryTest.kt with tests for hasSwiped functionality.
Stuck points:
- Encountered Kapt failures due to JDK 21 which required multiple attempts to correctly configure gradle.properties.
- Faced a NullPointerException in unit tests for the hasSwiped Flow, which was resolved by ensuring the dataStore mock is fully initialized before the repository and by using a getter for the property.
Co-authored-by: JesseScott <669104+JesseScott@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
are these additions necessary?
- Refactored `UserPreferencesRepository.hasSwiped` back to a property to avoid creating new Flow instances on every access, while ensuring it is correctly initialized. - Improved `UserPreferencesRepositoryTest` by providing a default mock for `dataStore.data` in `setUp`, preventing `NullPointerException` in tests that don't explicitly mock it. - Verified all unit tests pass (11 tests successful). - Fixes the issue where the "swipe to see more" snackbar would always appear due to incorrect coroutine management and failure to load the persisted state. Note: I attempted to review the pull request comments, but the automated function was unavailable. I have proceeded with final verification and cleanup. Co-authored-by: JesseScott <669104+JesseScott@users.noreply.github.com>
- Fixed the "swipe to see more" snackbar logic in `MainActivity.kt` by ensuring the coroutine is cancelled when the swipe state changes.
- Updated `UserPreferencesRepository` to correctly handle the `hasSwiped` state, including adding it to the `UserPreferences` model and `fetchInitialPreferences`.
- Resolved CI failure (NullPointerException in tests) by:
- Initializing `dataStore.data` mock with an empty preferences flow in `setUp`.
- Creating a local `UserPreferencesRepository` instance in tests that require a specific initial flow for the `hasSwiped` property.
- Fixed build issues by adding necessary JDK 21 `--add-opens` arguments to `gradle.properties`.
- Verified all unit tests pass locally.
Co-authored-by: JesseScott <669104+JesseScott@users.noreply.github.com>
This PR fixes the issue where the "swipe to see more" snackbar would always appear even if the user had already swiped. The fix involves correcting the coroutine usage in MainActivity to allow for cancellation and fixing the UserPreferencesRepository to correctly read and return the hasSwiped state from DataStore. It also includes necessary build configuration fixes for JDK 21 compatibility.
Fixes #92
PR created automatically by Jules for task 15752565676927284513 started by @JesseScott