Compare commits

...
Author SHA1 Message Date
Marcel Hibbe 2946d5fded 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 <[email protected]>
2026-09-21 13:18:54 +02:00
@@ -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) {