-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add visual indicator of read/unread news resources #595
Conversation
0a5d076
to
241e9ce
Compare
9b8cc77
to
973ca2b
Compare
This moves the responsibility for joining the UserData and the NewsResources to UserNewsResourceRepository. This way, the work can be done once and shared with all consumers in a SharedFlow, rather than having each consumer perform the join itself by invoking the UseCase.
When a news resource is unread, display a dot on its card in the news feed. When the For You section has unread resources, display a dot on its icon in the navigation bar. Update the read status when a resource is opened.
973ca2b
to
ebfbb5b
Compare
Please add screenshots of "before" and "after" to the PR description, as well as details about what this change does and why. |
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.
Thanks for adding this. From the user's POV this works really well, especially the nav icon, which makes it super clear when you've got content you haven't read.
From an architectural POV there are some issues which are only clear now you've implemented it :)
The main pieces of feedback are:
- The cold->hot flow adds a lot of complexity for little benefit, let's remove it
- We need to decide on whether we want to keep
UserNewsRepo
or refactor this into multiple use cases (jury still out on this). - Move the notification state out of
NiaApp
intoNiaAppState
app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt
Outdated
Show resolved
Hide resolved
...ogle/samples/apps/nowinandroid/core/domain/repository/CompositeUserNewsResourceRepository.kt
Outdated
Show resolved
Hide resolved
...ain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt
Outdated
Show resolved
Hide resolved
...ogle/samples/apps/nowinandroid/core/domain/repository/CompositeUserNewsResourceRepository.kt
Outdated
Show resolved
Hide resolved
.../foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt
Outdated
Show resolved
Hide resolved
...s/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt
Outdated
Show resolved
Hide resolved
.../foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt
Outdated
Show resolved
Hide resolved
8194f7a
to
519b82f
Compare
module; move UserNewsResource to model module. Implement unread dot for bookmarked articles. Keep the flows cold in UserNewsResourceRepository.
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.
LGTM with some minor method name changes.
...java/com/google/samples/apps/nowinandroid/core/data/repository/UserNewsResourceRepository.kt
Outdated
Show resolved
Hide resolved
...java/com/google/samples/apps/nowinandroid/core/data/repository/UserNewsResourceRepository.kt
Outdated
Show resolved
Hide resolved
...java/com/google/samples/apps/nowinandroid/core/data/repository/UserNewsResourceRepository.kt
Outdated
Show resolved
Hide resolved
As per internal discussion, let's also set all current news resources to read status so that the user is only notified of new items. |
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.
Thanks for doing this. Looking good.
Adds indicator dots when a news resource is unread, and when a navigation destination has unread content. Makes necessary data layer changes to track resources that have been read. This makes it easier for users to quickly scan for content that they haven't seen already or identify content that they have already read.