From aeacfa09b6037eca18a7c03df01134201e03fcf8 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 24 Sep 2024 14:18:25 +0200 Subject: [PATCH] avoid UninitializedPropertyAccessException for spreedCapabilities 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 --- app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 7d4a4d9027..dda05c6e7c 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -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()") } }