Skip to content

Commit

Permalink
Fix crash when refreshing current item
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Jul 6, 2024
1 parent f6f81c2 commit fda20e0
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,12 @@ fun ItemRowAdapter.refreshItem(
}.fold(
onSuccess = { refreshedBaseItem ->
withContext(Dispatchers.Main) {
val index = indexOf(currentBaseRowItem)
// Item could be removed while API was loading, check if the index is valid first
if (index == -1) return@withContext

set(
index = indexOf(currentBaseRowItem),
index = index,
element = BaseItemDtoBaseRowItem(
item = refreshedBaseItem,
preferParentThumb = currentBaseRowItem.preferParentThumb,
Expand Down

0 comments on commit fda20e0

Please sign in to comment.