Fixed crashes related to lateinit property used before being initialized found on Crashlytics

This commit is contained in:
Sylvain Berfini 2025-07-17 09:40:47 +02:00
parent c32bac7b07
commit 70df098ee4
2 changed files with 12 additions and 7 deletions

View file

@ -180,12 +180,14 @@ class ContactViewModel
private val contactsListener = object : ContactsManager.ContactsListener { private val contactsListener = object : ContactsManager.ContactsListener {
@WorkerThread @WorkerThread
override fun onContactsLoaded() { override fun onContactsLoaded() {
val friend = coreContext.contactsManager.findContactById(refKey) if (!::friend.isInitialized) return
if (friend != null && friend != this@ContactViewModel.friend) {
val found = coreContext.contactsManager.findContactById(refKey)
if (found != null && found != friend) {
Log.i( Log.i(
"$TAG Found contact [${friend.name}] matching ref key [$refKey] after contacts have been loaded/updated" "$TAG Found contact [${found.name}] matching ref key [$refKey] after contacts have been loaded/updated"
) )
this@ContactViewModel.friend = friend friend = found
refreshContactInfo() refreshContactInfo()
} }
} }

View file

@ -192,6 +192,7 @@ class HistoryViewModel
@UiThread @UiThread
fun startAudioCall() { fun startAudioCall() {
coreContext.postOnCoreThread { core -> coreContext.postOnCoreThread { core ->
if (!::address.isInitialized) return@postOnCoreThread
coreContext.startAudioCall(address) coreContext.startAudioCall(address)
} }
} }
@ -199,6 +200,7 @@ class HistoryViewModel
@UiThread @UiThread
fun startVideoCall() { fun startVideoCall() {
coreContext.postOnCoreThread { core -> coreContext.postOnCoreThread { core ->
if (!::address.isInitialized) return@postOnCoreThread
coreContext.startVideoCall(address) coreContext.startVideoCall(address)
} }
} }
@ -218,6 +220,8 @@ class HistoryViewModel
@UiThread @UiThread
fun goToConversation() { fun goToConversation() {
coreContext.postOnCoreThread { core -> coreContext.postOnCoreThread { core ->
if (!::address.isInitialized) return@postOnCoreThread
val account = core.defaultAccount val account = core.defaultAccount
val localSipUri = account?.params?.identityAddress?.asStringUriOnly() val localSipUri = account?.params?.identityAddress?.asStringUriOnly()
if (!localSipUri.isNullOrEmpty()) { if (!localSipUri.isNullOrEmpty()) {
@ -315,9 +319,8 @@ class HistoryViewModel
@UiThread @UiThread
fun goToMeetingWaitingRoom() { fun goToMeetingWaitingRoom() {
coreContext.postOnCoreThread { coreContext.postOnCoreThread {
if (::address.isInitialized) { if (!::address.isInitialized) return@postOnCoreThread
conferenceToJoinEvent.postValue(Event(address.asStringUriOnly())) conferenceToJoinEvent.postValue(Event(address.asStringUriOnly()))
}
} }
} }