Skip to content

Commit

Permalink
fix(ResourceActivity): related resources duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
urFate committed Sep 21, 2024
1 parent dfa30f0 commit 91ebcc2
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,15 @@ class ResourceViewModel @Inject constructor(@ApplicationContext context: Context

fun fetchRelated(shikimoriID: Int) {
viewModelScope.launch(Dispatchers.IO) {
ShikimoriRepository.fetchRelated(shikimoriID, ANIME).catch {
it.printStackTrace()
emitAll(emptyFlow())
}.collect { contents ->
contents.forEach { it.let(relatedContents::add) }
}
ShikimoriRepository.fetchRelated(shikimoriID, ANIME)
.catch {
it.printStackTrace()
emitAll(emptyFlow())
}
.collect { contents ->
relatedContents.clear()
contents.forEach { it.let(relatedContents::add) }
}
}
}

Expand Down

0 comments on commit 91ebcc2

Please sign in to comment.