From 2946d5fded27fb95065a65cf05e30d6c3d650a29 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 21 Sep 2026 12:25:38 +0200 Subject: [PATCH] fix(chat): get currentUser from currentUserFlow in getRoom The lateinit currentUser is only set once ChatActivity's async initData() call completes, which can race with onResume() calling getRoom() and crash with UninitializedPropertyAccessException. currentUserFlow is populated eagerly and independently of that init sequencing, so use it instead - this removes the race rather than just guarding around it. Assisted-by: Claude Code:claude-sonnet-5 Signed-off-by: Marcel Hibbe --- .../com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt index 3d015f4837..01ead481ea 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt @@ -1742,8 +1742,12 @@ class ChatViewModel @AssistedInject constructor( @Deprecated("use observeConversation") fun getRoom(token: String) { - // _getRoomViewState.value = GetRoomStartState - conversationRepository.getRoom(currentUser, token) + val user = currentUserFlow.value + if (user == null) { + logger.w(TAG, "getRoom: user not initialized") + return + } + conversationRepository.getRoom(user, token) } fun loadScheduledMessages(credentials: String, url: String) {