mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-29 09:58:54 +03:00
Merge pull request #4261 from nextcloud/bugfix/4190/avoidNpeCurrentConversation
try to avoid NPE for currentConversation
This commit is contained in:
commit
c3270079b4
1 changed files with 46 additions and 31 deletions
|
@ -571,48 +571,63 @@ class ChatActivity :
|
||||||
chatViewModel.getCapabilitiesViewState.observe(this) { state ->
|
chatViewModel.getCapabilitiesViewState.observe(this) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is ChatViewModel.GetCapabilitiesUpdateState -> {
|
is ChatViewModel.GetCapabilitiesUpdateState -> {
|
||||||
spreedCapabilities = state.spreedCapabilities
|
if (currentConversation != null) {
|
||||||
chatApiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(1))
|
spreedCapabilities = state.spreedCapabilities
|
||||||
participantPermissions = ParticipantPermissions(spreedCapabilities, currentConversation!!)
|
chatApiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(1))
|
||||||
|
participantPermissions = ParticipantPermissions(spreedCapabilities, currentConversation!!)
|
||||||
|
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
checkShowCallButtons()
|
checkShowCallButtons()
|
||||||
checkLobbyState()
|
checkLobbyState()
|
||||||
updateRoomTimerHandler()
|
updateRoomTimerHandler()
|
||||||
|
} else {
|
||||||
|
Log.w(
|
||||||
|
TAG,
|
||||||
|
"currentConversation was null in observer ChatViewModel.GetCapabilitiesUpdateState"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is ChatViewModel.GetCapabilitiesInitialLoadState -> {
|
is ChatViewModel.GetCapabilitiesInitialLoadState -> {
|
||||||
spreedCapabilities = state.spreedCapabilities
|
if (currentConversation != null) {
|
||||||
chatApiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(1))
|
spreedCapabilities = state.spreedCapabilities
|
||||||
participantPermissions = ParticipantPermissions(spreedCapabilities, currentConversation!!)
|
chatApiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(1))
|
||||||
|
participantPermissions = ParticipantPermissions(spreedCapabilities, currentConversation!!)
|
||||||
|
|
||||||
supportFragmentManager.commit {
|
supportFragmentManager.commit {
|
||||||
setReorderingAllowed(true) // optimizes out redundant replace operations
|
setReorderingAllowed(true) // optimizes out redundant replace operations
|
||||||
replace(R.id.fragment_container_activity_chat, messageInputFragment)
|
replace(R.id.fragment_container_activity_chat, messageInputFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
joinRoomWithPassword()
|
joinRoomWithPassword()
|
||||||
|
|
||||||
if (conversationUser?.userId != "?" &&
|
if (conversationUser?.userId != "?" &&
|
||||||
CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.MENTION_FLAG)
|
CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.MENTION_FLAG)
|
||||||
) {
|
) {
|
||||||
binding.chatToolbar.setOnClickListener { _ -> showConversationInfoScreen() }
|
binding.chatToolbar.setOnClickListener { _ -> showConversationInfoScreen() }
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAvatarForStatusBar()
|
loadAvatarForStatusBar()
|
||||||
setupSwipeToReply()
|
setupSwipeToReply()
|
||||||
setActionBarTitle()
|
setActionBarTitle()
|
||||||
|
|
||||||
checkShowCallButtons()
|
checkShowCallButtons()
|
||||||
checkLobbyState()
|
checkLobbyState()
|
||||||
updateRoomTimerHandler()
|
updateRoomTimerHandler()
|
||||||
|
|
||||||
val urlForChatting = ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
val urlForChatting =
|
||||||
|
ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
||||||
|
|
||||||
if (adapter?.isEmpty == true) {
|
if (adapter?.isEmpty == true) {
|
||||||
chatViewModel.loadMessages(
|
chatViewModel.loadMessages(
|
||||||
withCredentials = credentials!!,
|
withCredentials = credentials!!,
|
||||||
withUrl = urlForChatting
|
withUrl = urlForChatting
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.w(
|
||||||
|
TAG,
|
||||||
|
"currentConversation was null in observer ChatViewModel.GetCapabilitiesInitialLoadState"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue