Skip to content

Commit

Permalink
avoid UninitializedPropertyAccessException for spreedCapabilities
Browse files Browse the repository at this point in the history
reported issue on gplay console was:

Exception kotlin.UninitializedPropertyAccessException: lateinit property spreedCapabilities has not been initialized
  at com.nextcloud.talk.chat.ChatActivity.getSpreedCapabilities (ChatActivity.kt:284)
  at com.nextcloud.talk.chat.ChatActivity.processExpiredMessages (ChatActivity.kt:2536)
  at com.nextcloud.talk.chat.ChatActivity.access$processExpiredMessages (ChatActivity.kt:204)
  at com.nextcloud.talk.chat.ChatActivity$initObservers$10$1.invokeSuspend (ChatActivity.kt:820)

This is just a hotfix while hoping processExpiredMessages is executed again while spreedCapabilities are available.

To improve the situation in the long term, we should move more logic to viewModel and have better control over sequence of actions.

Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Sep 24, 2024
1 parent 715017d commit 034c8c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2535,8 +2535,12 @@ class ChatActivity :
}
}

if (CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.MESSAGE_EXPIRATION)) {
deleteExpiredMessages()
if (this::spreedCapabilities.isInitialized) {
if (CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.MESSAGE_EXPIRATION)) {
deleteExpiredMessages()
}
} else {
Log.w(TAG, "spreedCapabilities are not initialized in processExpiredMessages()")
}
}

Expand Down Expand Up @@ -3240,7 +3244,7 @@ class ChatActivity :
val lon = data["longitude"]!!
metaData =
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
}

when (type) {
Expand Down

0 comments on commit 034c8c9

Please sign in to comment.