Fixed race condition issue on avatarsMap + listener removed by mistake

This commit is contained in:
Sylvain Berfini 2023-11-16 22:31:04 +01:00
parent b113e2b729
commit 5f5885cb18
3 changed files with 10 additions and 4 deletions

View file

@ -127,10 +127,10 @@ class ContactsManager @UiThread constructor(context: Context) {
fun onNativeContactsLoaded() {
nativeContactsLoaded = true
avatarsMap.values.forEach(ContactAvatarModel::destroy)
avatarsMap.clear()
coreContext.postOnCoreThread {
avatarsMap.values.forEach(ContactAvatarModel::destroy)
avatarsMap.clear()
notifyContactsListChanged()
}
}

View file

@ -116,7 +116,9 @@ class DrawerMenuFragment : GenericFragment() {
viewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
it.consume { identity ->
Log.w("$TAG Default account has changed, now is [$identity], closing side menu in 500ms")
Log.w(
"$TAG Default account has changed, now is [$identity], closing side menu in 500ms"
)
sharedViewModel.defaultAccountChangedEvent.value = Event(true)
lifecycleScope.launch {

View file

@ -121,6 +121,10 @@ open class AbstractTopBarViewModel @UiThread constructor() : ViewModel() {
init {
searchBarVisible.value = false
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
}
update()
}