Skip to content

Commit

Permalink
fix: Don't clear content when account changes (#1132)
Browse files Browse the repository at this point in the history
Previous code ran the setup routine whenever the account changed. I
think this could result in the content being cleared when a notification
arrived (processing the notification updates the marker, which updates
the account, which triggers a new collection).

Fix this by only taking the first emission of the account from the flow
to do the setup.
  • Loading branch information
nikclayton authored Nov 25, 2024
1 parent fa50b2d commit 2ebb77e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ import kotlin.math.max
import kotlin.math.min
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
import timber.log.Timber

Expand Down Expand Up @@ -276,7 +276,7 @@ class ComposeActivity :
)

lifecycleScope.launch {
viewModel.accountFlow.distinctUntilChanged().collect { account ->
viewModel.accountFlow.take(1).collect { account ->
setupAvatar(account.entity)

if (viewModel.displaySelfUsername) {
Expand Down

0 comments on commit 2ebb77e

Please sign in to comment.