-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
Convert NotificationsFragment and related code to Kotlin, use the Paging library #3159
Merged
connyduck
merged 147 commits into
tuskyapp:develop
from
nikclayton:2kt-notifications-fragment
Mar 10, 2023
Merged
Convert NotificationsFragment and related code to Kotlin, use the Paging library #3159
connyduck
merged 147 commits into
tuskyapp:develop
from
nikclayton:2kt-notifications-fragment
Mar 10, 2023
Conversation
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
- Use `lateinit` for `eventhub`, `adapter`, `preferences`, and `scrolllistener` - Removed override for accountManager, it can be used from the superclass - Add `?.` where non-nullity could not (yet) be guaranteed - Remove `?` from type lists where non-nullity is guaranteed - Explicitly convert lists to mutable where necessary - Delete unused function `findReplyPosition`
The previous change meant some values are no longer nullable. Remove the non-null assertions.
- Remove redundant constructor - Move block outside of `()`
- Access the last value with `.last()` - Access the last index with `.lastIndex` - Replace logical-chain with `asRightOrNull` and `?.` - `.isNotEmpty()`, not `!...isEmpty()`
Does not compile, this is the unchanged output of the "Convert to Kotlin" function
…nsFragment.kt Co-authored-by: Konrad Pozniak <[email protected]>
… 2kt-notifications-fragment # Conflicts: # app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.kt
The popup window: - Is inconsistent UI - Requires a custom layout - Didn't play nicely with viewbinding
# Conflicts: # app/src/main/java/com/keylesspalace/tusky/di/ViewModelFactory.kt # app/src/main/res/values/strings.xml
# Conflicts: # app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java # app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java # gradle/libs.versions.toml
# Conflicts: # app/src/main/java/com/keylesspalace/tusky/TabData.kt # app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java # app/src/main/res/menu/fragment_notifications.xml
Lakoja
reviewed
Mar 9, 2023
app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt
Show resolved
Hide resolved
...rc/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsAdapter.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/FollowViewHolder.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsRepository.kt
Show resolved
Hide resolved
nikclayton
commented
Mar 9, 2023
connyduck
approved these changes
Mar 10, 2023
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.
"Load more" is gone. When the user opens notifications their position in the list is restored (if the notification still exists) and new/old notifications are fetched in the background as the user scrolls.
If an error occurs during a network operation the user is shown the error, with an opportunity to retry it. If the UI opportunistically showed the operation as succeeding (e.g., try and bookmark a status in airplane mode with the previous code, it will show the bookmark as succeeding) the UI is reset to show the operation did not succeed.
Preference changes that affect the display of the list (e.g., toggling "Show media previews") do not reload the list.
Apart from the Kotlin re-write, the code has been split up in to:
This significantly simplifies which code is responsible for what. For example, the Fragment, ViewModel, and Repository do not interact with the Mastodon API (for notifications), that is entirely within the PagingSource.
Fragment communicates actions to ViewModel by sending instances of UiAction. ViewModel communicates state to Fragment through different flows.
Preference changes are encapsulated in ViewModel, and are communicated through the UI state.
With no need for "Load more" support, the distinction between ".Concrete" and ".Placeholder" types is unnecessary, the ".Placeholder" type has been removed, and ".Concrete" merged in to "Notification".
EventHub is not needed in the Fragment. ViewModel still needs it for PreferenceChangedEvent, but in future work I plan to implement a PreferencesRepository that obsoletes it.
Separate ViewHolder classes have been created for all the notification types.
Fixes #2726, #1258