ensure that there is always a current user

this should also fix the app to start after it always crashed on startup because of https://github.com/nextcloud/talk-android/issues/2531

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-12-14 15:50:07 +01:00 committed by Andy Scherzinger
parent dd155db6ab
commit e238c4c9e5
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 2 additions and 1 deletions

View file

@ -295,7 +295,7 @@ class ConversationsListController(bundle: Bundle) :
} }
fetchRooms() fetchRooms()
} else { } else {
Log.e(TAG, "currentUser was null in ConversationsListController.onAttach") Log.e(TAG, "userManager.currentUser.blockingGet() returned null")
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show() Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
} }
} }

View file

@ -43,6 +43,7 @@ class UserManager internal constructor(private val userRepository: UsersReposito
val currentUser: Maybe<User> val currentUser: Maybe<User>
get() { get() {
return userRepository.getActiveUser() return userRepository.getActiveUser()
.switchIfEmpty(getAnyUserAndSetAsActive())
} }
val currentUserObservable: Observable<User> val currentUserObservable: Observable<User>