mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
use setUserAsActive instead of userManager.disableAllUsersWithoutId
just refactoring for now. this doesn't solve the bug! Problem that needs to be solved: When adding a new Account (User), it is marked as "current", while for the other logged in users "current" must be unset (-> disabled). The problem is, that for the old active user, "current" is not unset so there were multiple accounts marked as "current". In the ChooseAccountDialogFragment, only one of the current accounts is shown at the top. Below the set status field, all accounts are listed that are not marked with "current". So as a result, there can be accounts hidden that were marked as "current". Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
82b4907118
commit
d4e545e67d
@ -28,6 +28,7 @@ import android.os.Handler
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.work.Data
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
@ -443,25 +444,33 @@ class AccountVerificationController(args: Bundle? = null) :
|
||||
}
|
||||
|
||||
private fun proceedWithLogin() {
|
||||
Log.d(TAG, "proceedWithLogin...")
|
||||
cookieManager.cookieStore.removeAll()
|
||||
val userDisabledCount = userManager.disableAllUsersWithoutId(internalAccountId).blockingGet()
|
||||
Log.d(TAG, "Disabled $userDisabledCount users that had no id")
|
||||
if (activity != null) {
|
||||
activity!!.runOnUiThread {
|
||||
if (userManager.users.blockingGet().size == 1) {
|
||||
router.setRoot(
|
||||
RouterTransaction.with(ConversationsListController(Bundle()))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
)
|
||||
} else {
|
||||
if (isAccountImport) {
|
||||
ApplicationWideMessageHolder.getInstance().messageType =
|
||||
ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED
|
||||
|
||||
val userToSetAsActive = userManager.getUserWithId(internalAccountId).blockingGet()
|
||||
Log.d(TAG, "userToSetAsActive: " + userToSetAsActive.username)
|
||||
|
||||
if (userManager.setUserAsActive(userToSetAsActive).blockingGet()) {
|
||||
if (activity != null) {
|
||||
activity!!.runOnUiThread {
|
||||
if (userManager.users.blockingGet().size == 1) {
|
||||
router.setRoot(
|
||||
RouterTransaction.with(ConversationsListController(Bundle()))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
)
|
||||
} else {
|
||||
if (isAccountImport) {
|
||||
ApplicationWideMessageHolder.getInstance().messageType =
|
||||
ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED
|
||||
}
|
||||
router.popToRoot()
|
||||
}
|
||||
router.popToRoot()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "failed to set active user")
|
||||
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,6 @@ abstract class UsersDao {
|
||||
@Query("SELECT * FROM User where userId = :userId")
|
||||
abstract fun getUserWithUserId(userId: String): Maybe<UserEntity>
|
||||
|
||||
@Query("SELECT * FROM User where id != :id")
|
||||
abstract fun getUsersWithoutId(id: Long): Single<List<UserEntity>>
|
||||
|
||||
@Query("SELECT * FROM User where scheduledForDeletion = 1")
|
||||
abstract fun getUsersScheduledForDeletion(): Single<List<UserEntity>>
|
||||
|
||||
@ -92,6 +89,13 @@ abstract class UsersDao {
|
||||
return try {
|
||||
getUsers().blockingGet().forEach { user ->
|
||||
user.current = user.id == id
|
||||
|
||||
Log.d(TAG, "xxxxxxxxxxxx")
|
||||
Log.d(TAG, "setUserAsActiveWithId. user.username: " + user.username)
|
||||
Log.d(TAG, "setUserAsActiveWithId. user.id: " + user.id)
|
||||
Log.d(TAG, "setUserAsActiveWithId. user.current: " + user.current)
|
||||
Log.d(TAG, "xxxxxxxxxxxx")
|
||||
|
||||
updateUser(user)
|
||||
}
|
||||
true
|
||||
|
@ -35,7 +35,6 @@ interface UsersRepository {
|
||||
fun getUserWithId(id: Long): Maybe<User>
|
||||
fun getUserWithIdNotScheduledForDeletion(id: Long): Maybe<User>
|
||||
fun getUserWithUserId(userId: String): Maybe<User>
|
||||
fun getUsersWithoutUserId(id: Long): Single<List<User>>
|
||||
fun getUsersScheduledForDeletion(): Single<List<User>>
|
||||
fun getUsersNotScheduledForDeletion(): Single<List<User>>
|
||||
fun getUserWithUsernameAndServer(username: String, server: String): Maybe<User>
|
||||
|
@ -54,10 +54,6 @@ class UsersRepositoryImpl(private val usersDao: UsersDao) : UsersRepository {
|
||||
return usersDao.getUserWithUserId(userId).map { UserMapper.toModel(it) }
|
||||
}
|
||||
|
||||
override fun getUsersWithoutUserId(id: Long): Single<List<User>> {
|
||||
return usersDao.getUsersWithoutId(id).map { UserMapper.toModel(it) }
|
||||
}
|
||||
|
||||
override fun getUsersScheduledForDeletion(): Single<List<User>> {
|
||||
return usersDao.getUsersScheduledForDeletion().map { UserMapper.toModel(it) }
|
||||
}
|
||||
|
@ -148,6 +148,11 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
||||
|
||||
for (Object userItem : userManager.getUsers().blockingGet()) {
|
||||
userEntity = (User) userItem;
|
||||
Log.d(TAG, "---------------------");
|
||||
Log.d(TAG, "userEntity.getUserId() " + userEntity.getUserId());
|
||||
Log.d(TAG, "userEntity.getCurrent() " + userEntity.getCurrent());
|
||||
Log.d(TAG, "---------------------");
|
||||
|
||||
if (!userEntity.getCurrent()) {
|
||||
String userId;
|
||||
if (userEntity.getUserId() != null) {
|
||||
|
@ -58,22 +58,6 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
||||
return userRepository.getUserWithId(id)
|
||||
}
|
||||
|
||||
fun disableAllUsersWithoutId(id: Long): Single<Int> {
|
||||
val results = userRepository.getUsersWithoutUserId(id)
|
||||
|
||||
return results.map { users ->
|
||||
var count = 0
|
||||
if (users.isNotEmpty()) {
|
||||
for (entity in users) {
|
||||
entity.current = false
|
||||
userRepository.updateUser(entity)
|
||||
count++
|
||||
}
|
||||
}
|
||||
count
|
||||
}
|
||||
}
|
||||
|
||||
fun checkIfUserIsScheduledForDeletion(username: String, server: String): Single<Boolean> {
|
||||
return userRepository
|
||||
.getUserWithUsernameAndServer(username, server)
|
||||
|
Loading…
Reference in New Issue
Block a user