Merge pull request #4611 from nextcloud/bugfix/4610/fixNpeCurrentUserInConvList

hopefully fix NPE for currentUser in addToConversationItems
This commit is contained in:
Marcel Hibbe 2025-01-16 12:48:53 +00:00 committed by GitHub
commit ce7ed877ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -235,6 +235,8 @@ class ConversationsListActivity :
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this) NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
currentUser = currentUserProvider.currentUser.blockingGet()
conversationsListViewModel = ViewModelProvider(this, viewModelFactory)[ConversationsListViewModel::class.java] conversationsListViewModel = ViewModelProvider(this, viewModelFactory)[ConversationsListViewModel::class.java]
binding = ActivityConversationsBinding.inflate(layoutInflater) binding = ActivityConversationsBinding.inflate(layoutInflater)
@ -284,7 +286,7 @@ class ConversationsListActivity :
if (!eventBus.isRegistered(this)) { if (!eventBus.isRegistered(this)) {
eventBus.register(this) eventBus.register(this)
} }
currentUser = userManager.currentUser.blockingGet()
if (currentUser != null) { if (currentUser != null) {
if (isServerEOL(currentUser!!.serverVersion?.major)) { if (isServerEOL(currentUser!!.serverVersion?.major)) {
showServerEOLDialog() showServerEOLDialog()
@ -309,7 +311,7 @@ class ConversationsListActivity :
fetchRooms() fetchRooms()
fetchPendingInvitations() fetchPendingInvitations()
} else { } else {
Log.e(TAG, "userManager.currentUser.blockingGet() returned null") Log.e(TAG, "currentUser was null")
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show() Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
} }
@ -421,7 +423,7 @@ class ConversationsListActivity :
} }
fun filterConversation() { fun filterConversation() {
val accountId = UserIdUtils.getIdForUser(userManager.currentUser.blockingGet()) val accountId = UserIdUtils.getIdForUser(currentUser)
filterState[FilterConversationFragment.UNREAD] = ( filterState[FilterConversationFragment.UNREAD] = (
arbitraryStorageManager.getStorageSetting( arbitraryStorageManager.getStorageSetting(
accountId, accountId,
@ -1365,7 +1367,7 @@ class ConversationsListActivity :
val conversation = clickedItem.model val conversation = clickedItem.model
conversationsListBottomDialog = ConversationsListBottomDialog( conversationsListBottomDialog = ConversationsListBottomDialog(
this@ConversationsListActivity, this@ConversationsListActivity,
userManager.currentUser.blockingGet(), currentUser!!,
conversation conversation
) )
conversationsListBottomDialog!!.show() conversationsListBottomDialog!!.show()
@ -1557,7 +1559,7 @@ class ConversationsListActivity :
val callsChannelNotEnabled = !NotificationUtils.isCallsNotificationChannelEnabled(this) val callsChannelNotEnabled = !NotificationUtils.isCallsNotificationChannelEnabled(this)
val serverNotificationAppInstalled = val serverNotificationAppInstalled =
userManager.currentUser.blockingGet().capabilities?.notificationsCapability?.features?.isNotEmpty() ?: false currentUser?.capabilities?.notificationsCapability?.features?.isNotEmpty() ?: false
val settingsOfUserAreWrong = notificationPermissionNotGranted || val settingsOfUserAreWrong = notificationPermissionNotGranted ||
batteryOptimizationNotIgnored || batteryOptimizationNotIgnored ||