Skip to content

Commit d760290

Browse files
sirambdKevinBoulongne
authored andcommitted
fix: IllegalStateException in AvatarView.avatarUpdateObserve
Fixes MAIL-ANDROID-55P, fixes MAIL-ANDROID-DG5, fixes MAIL-ANDROID-D2W, fixes MAIL-ANDROID-E08
1 parent 6fa22c3 commit d760290

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/src/main/java/com/infomaniak/mail/views/AvatarView.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import com.infomaniak.mail.data.models.correspondent.MergedContact
4343
import com.infomaniak.mail.databinding.ViewAvatarBinding
4444
import com.infomaniak.mail.utils.AccountUtils
4545
import com.infomaniak.mail.utils.Utils
46+
import com.infomaniak.mail.utils.Utils.runCatchingRealm
4647
import com.infomaniak.mail.utils.extensions.MergedContactDictionary
4748
import com.infomaniak.mail.utils.extensions.getColorOrNull
4849
import com.infomaniak.mail.utils.extensions.getTransparentColor
@@ -71,11 +72,13 @@ class AvatarView @JvmOverloads constructor(
7172
}
7273

7374
private val avatarUpdateObserver = Observer<Pair<MergedContactDictionary, Boolean>> { (contacts, isBimiEnabled) ->
74-
val (correspondent, bimi) = state
75-
val displayType = getAvatarDisplayType(correspondent, bimi, isBimiEnabled)
75+
runCatchingRealm {
76+
val (correspondent, bimi) = state
77+
val displayType = getAvatarDisplayType(correspondent, bimi, isBimiEnabled)
7678

77-
if (displayType == AvatarDisplayType.UNKNOWN_CORRESPONDENT) return@Observer
78-
loadAvatarByDisplayType(displayType, correspondent, bimi, contacts)
79+
if (displayType == AvatarDisplayType.UNKNOWN_CORRESPONDENT) return@Observer
80+
loadAvatarByDisplayType(displayType, correspondent, bimi, contacts)
81+
}
7982
}
8083

8184
@Inject

0 commit comments

Comments
 (0)