Merge pull request #3514 from Lakoja/fix-edgy-crashes

Do not crash on/avoid index out of bounds
This commit is contained in:
Nik Clayton 2023-04-21 19:52:45 +02:00 committed by GitHub
commit b57db0589d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -161,7 +161,7 @@ class NotificationsFragment :
binding.recyclerView,
this
) { pos: Int ->
val notification = adapter.snapshot()[pos]
val notification = adapter.snapshot().getOrNull(pos)
// We support replies only for now
if (notification is NotificationViewData) {
notification.statusViewData

View file

@ -478,7 +478,7 @@ class TimelineFragment :
override fun onLoadMore(position: Int) {
val placeholder = adapter.peek(position)?.asPlaceholderOrNull() ?: return
loadMorePosition = position
statusIdBelowLoadMore = adapter.peek(position + 1)?.id
statusIdBelowLoadMore = if (position + 1 < adapter.itemCount) adapter.peek(position + 1)?.id else null
viewModel.loadMore(placeholder.id)
}