mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-14 16:25:05 +01:00
Fix selecting contacts
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
1b5b8beda3
commit
cbd73164e2
@ -43,7 +43,6 @@ import com.nextcloud.talk.utils.PushUtils
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.net.URLDecoder
|
||||
|
@ -57,7 +57,7 @@ class ChatViewModel constructor(application: Application,
|
||||
fun init(user: UserNgEntity, conversationToken: String, conversationPassword: String?) {
|
||||
viewModelScope.launch {
|
||||
this@ChatViewModel.user = user
|
||||
this@ChatViewModel.initConversation = conversationsRepository.getConversationForUserWithToken(user.id!!, conversationToken)
|
||||
this@ChatViewModel.initConversation = conversationsRepository.getConversationForUserWithToken(user.id, conversationToken)
|
||||
this@ChatViewModel.conversationPassword = conversationPassword
|
||||
globalService.getConversation(conversationToken, this@ChatViewModel)
|
||||
}
|
||||
@ -70,7 +70,7 @@ class ChatViewModel constructor(application: Application,
|
||||
override suspend fun gotConversationInfoForUser(userNgEntity: UserNgEntity, conversation: Conversation?, operationStatus: GlobalServiceInterface.OperationStatus) {
|
||||
if (operationStatus == GlobalServiceInterface.OperationStatus.STATUS_OK) {
|
||||
if (userNgEntity.id == user.id && conversation!!.token == initConversation?.token) {
|
||||
this.conversation.value = conversationsRepository.getConversationForUserWithToken(user.id!!, conversation.token!!)
|
||||
this.conversation.value = conversationsRepository.getConversationForUserWithToken(user.id, conversation.token!!)
|
||||
conversation.token?.let { conversationToken ->
|
||||
globalService.joinConversation(conversationToken, conversationPassword, this)
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
package com.nextcloud.talk.newarch.features.contactsflow.contacts
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -42,6 +41,7 @@ import com.nextcloud.talk.controllers.ChatController
|
||||
import com.nextcloud.talk.models.json.participants.Participant
|
||||
import com.nextcloud.talk.newarch.data.presenters.AdvancedEmptyPresenter
|
||||
import com.nextcloud.talk.newarch.features.contactsflow.ContactsViewOperationState
|
||||
import com.nextcloud.talk.newarch.features.contactsflow.ParticipantElement
|
||||
import com.nextcloud.talk.newarch.features.contactsflow.groupconversation.GroupConversationView
|
||||
import com.nextcloud.talk.newarch.features.search.DebouncingTextWatcher
|
||||
import com.nextcloud.talk.newarch.mvvm.BaseView
|
||||
@ -168,8 +168,6 @@ class ContactsView(private val bundle: Bundle? = null) : BaseView() {
|
||||
}
|
||||
|
||||
selectedParticipantsLiveData.observe(this@ContactsView) { participants ->
|
||||
view.selectedParticipantsRecyclerView.isVisible = participants.isNotEmpty()
|
||||
view.divider.isVisible = participants.isNotEmpty()
|
||||
floatingActionButton?.isVisible = participants.isNotEmpty()
|
||||
|
||||
}
|
||||
@ -223,29 +221,24 @@ class ContactsView(private val bundle: Bundle? = null) : BaseView() {
|
||||
}
|
||||
|
||||
private fun onElementClick(page: Page, holder: Presenter.Holder, element: Element<Any>) {
|
||||
if (element.data is Participant?) {
|
||||
val participant = element.data as Participant?
|
||||
if (element.type == ParticipantElementType.PARTICIPANT.ordinal || element.type == ParticipantElementType.PARTICIPANT_SELECTED.ordinal) {
|
||||
val participantElement = element.data as ParticipantElement
|
||||
val participant = participantElement.data as Participant
|
||||
|
||||
if (isNewGroupConversation || hasToken) {
|
||||
val isElementSelected = participant?.selected == true
|
||||
participant?.let {
|
||||
if (isElementSelected) {
|
||||
viewModel.unselectParticipant(it)
|
||||
if (participant.selected) {
|
||||
viewModel.unselectParticipant(participant)
|
||||
} else {
|
||||
viewModel.selectParticipant(it)
|
||||
viewModel.selectParticipant(participant)
|
||||
}
|
||||
it.selected = !isElementSelected
|
||||
participant.selected = !participant.selected
|
||||
if (element.type == ParticipantElementType.PARTICIPANT_SELECTED.ordinal) {
|
||||
participantsAdapter.notifyItemRangeChanged(0, participantsAdapter.itemCount, ElementPayload.SELECTION_TOGGLE)
|
||||
} else {
|
||||
participantsAdapter.notifyItemChanged(holder.adapterPosition, ElementPayload.SELECTION_TOGGLE)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
participant?.let {
|
||||
// One to one conversation
|
||||
viewModel.createConversation(1, it.userId)
|
||||
}
|
||||
viewModel.createConversation(1, participant.userId)
|
||||
}
|
||||
} else if (element.type == ParticipantElementType.PARTICIPANT_NEW_GROUP.ordinal) {
|
||||
router.replaceTopController(RouterTransaction.with(GroupConversationView())
|
||||
|
@ -97,7 +97,6 @@ class ContactsViewModel constructor(
|
||||
if (result.ocs.data.type == Conversation.ConversationType.ONE_TO_ONE_CONVERSATION || participants.isEmpty()) {
|
||||
result.ocs.data.token?.let {
|
||||
_operationState.postValue(ContactsViewOperationStateWrapper(ContactsViewOperationState.OK, null, it))
|
||||
|
||||
} ?: run {
|
||||
_operationState.postValue(ContactsViewOperationStateWrapper(ContactsViewOperationState.CONVERSATION_CREATION_FAILED, null, null))
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import com.otaliastudios.elements.Element
|
||||
import com.otaliastudios.elements.Page
|
||||
import com.otaliastudios.elements.Source
|
||||
import com.otaliastudios.elements.extensions.MainSource
|
||||
import java.lang.Exception
|
||||
|
||||
class ContactsViewSource<T : ParticipantElement>(private val data: LiveData<List<T>>, loadingIndicatorsEnabled: Boolean = true, errorIndicatorEnabled: Boolean = true, emptyIndicatorEnabled: Boolean = true) : MainSource<T>(loadingIndicatorsEnabled, errorIndicatorEnabled, emptyIndicatorEnabled) {
|
||||
private var currentPage: Page? = null
|
||||
@ -41,7 +40,7 @@ class ContactsViewSource<T : ParticipantElement>(private val data: LiveData<List
|
||||
}
|
||||
}
|
||||
|
||||
fun postError(exception: Exception){
|
||||
fun postError(exception: Exception) {
|
||||
currentPage?.let { page ->
|
||||
postResult(page, exception)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class ConversationsListView : BaseView() {
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, conversation.conversationId)
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(conversation))
|
||||
ConductorRemapping.remapChatController(
|
||||
router, user.id!!, conversation.token!!,
|
||||
router, user.id, conversation.token!!,
|
||||
bundle, false
|
||||
)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class ConversationsListViewModel constructor(
|
||||
filterLiveData.value = null
|
||||
Transformations.switchMap(filterLiveData) { filter ->
|
||||
if (user != null) {
|
||||
conversationsRepository.getConversationsForUser(user.id!!, filter)
|
||||
conversationsRepository.getConversationsForUser(user.id, filter)
|
||||
} else {
|
||||
liveData {
|
||||
listOf<Conversation>()
|
||||
@ -99,7 +99,7 @@ class ConversationsListViewModel constructor(
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override suspend fun onSuccess(result: GenericOverall) {
|
||||
conversationsRepository.deleteConversation(
|
||||
globalService.currentUserLiveData.value!!.id!!, conversation
|
||||
globalService.currentUserLiveData.value!!.id, conversation
|
||||
.conversationId!!
|
||||
)
|
||||
}
|
||||
@ -128,7 +128,7 @@ class ConversationsListViewModel constructor(
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override suspend fun onSuccess(result: GenericOverall) {
|
||||
conversationsRepository.deleteConversation(
|
||||
globalService.currentUserLiveData.value!!.id!!, conversation
|
||||
globalService.currentUserLiveData.value!!.id, conversation
|
||||
.conversationId!!
|
||||
)
|
||||
}
|
||||
@ -159,7 +159,7 @@ class ConversationsListViewModel constructor(
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override suspend fun onSuccess(result: GenericOverall) {
|
||||
conversationsRepository.setFavoriteValueForConversation(
|
||||
globalService.currentUserLiveData.value!!.id!!,
|
||||
globalService.currentUserLiveData.value!!.id,
|
||||
conversation.conversationId!!, favorite
|
||||
)
|
||||
}
|
||||
@ -202,7 +202,7 @@ class ConversationsListViewModel constructor(
|
||||
}
|
||||
|
||||
conversationsRepository.saveConversationsForUser(
|
||||
internalUserId!!,
|
||||
internalUserId,
|
||||
mutableList)
|
||||
messageData = ""
|
||||
conversationsLoadingLock.unlock()
|
||||
@ -223,7 +223,7 @@ class ConversationsListViewModel constructor(
|
||||
value: Boolean
|
||||
) {
|
||||
conversationsRepository.setChangingValueForConversation(
|
||||
globalService.currentUserLiveData.value!!.id!!, conversation
|
||||
globalService.currentUserLiveData.value!!.id, conversation
|
||||
.conversationId!!, value
|
||||
)
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class GlobalService constructor(usersRepository: UsersRepository,
|
||||
object : UseCaseResponse<ConversationOverall> {
|
||||
override suspend fun onSuccess(result: ConversationOverall) {
|
||||
currentUser?.let {
|
||||
conversationsRepository.saveConversationsForUser(it.id!!, listOf(result.ocs.data))
|
||||
conversationsRepository.saveConversationsForUser(it.id, listOf(result.ocs.data))
|
||||
globalServiceInterface.gotConversationInfoForUser(it, result.ocs.data, GlobalServiceInterface.OperationStatus.STATUS_OK)
|
||||
}
|
||||
}
|
||||
@ -94,8 +94,8 @@ class GlobalService constructor(usersRepository: UsersRepository,
|
||||
object : UseCaseResponse<ConversationOverall> {
|
||||
override suspend fun onSuccess(result: ConversationOverall) {
|
||||
currentUser?.let {
|
||||
conversationsRepository.saveConversationsForUser(it.id!!, listOf(result.ocs.data))
|
||||
currentConversation = conversationsRepository.getConversationForUserWithToken(it.id!!, result.ocs!!.data!!.token!!)
|
||||
conversationsRepository.saveConversationsForUser(it.id, listOf(result.ocs.data))
|
||||
currentConversation = conversationsRepository.getConversationForUserWithToken(it.id, result.ocs!!.data!!.token!!)
|
||||
globalServiceInterface.joinedConversationForUser(it, currentConversation, GlobalServiceInterface.OperationStatus.STATUS_OK)
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class ShortcutService constructor(private var context: Context,
|
||||
currentUser = user
|
||||
var internalUserId: Long = -1
|
||||
currentUser?.let {
|
||||
internalUserId = it.id!!
|
||||
internalUserId = it.id
|
||||
}
|
||||
conversationsRepository.getShortcutTargetConversations(internalUserId)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_below="@id/selectedParticipantsRecyclerView"
|
||||
|
Loading…
Reference in New Issue
Block a user