mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Various bug fixes and improvements
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
9a00a8ac43
commit
fd81dd3d9b
@ -71,7 +71,7 @@ public class ConversationItem
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ConversationItem) {
|
||||
ConversationItem inItem = (ConversationItem) o;
|
||||
return conversation.equals(inItem.getModel());
|
||||
return conversation.getConversationId().equals(inItem.getModel().getConversationId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ public class CallController extends BaseController {
|
||||
@Override
|
||||
public void onNext(RoomsOverall roomsOverall) {
|
||||
for (Conversation conversation : roomsOverall.getOcs().getData()) {
|
||||
if (roomId.equals(conversation.getRoomId())) {
|
||||
if (roomId.equals(conversation.getConversationId())) {
|
||||
roomToken = conversation.getToken();
|
||||
break;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ public class CallNotificationController extends BaseController {
|
||||
@Override
|
||||
public void onNext(RoomsOverall roomsOverall) {
|
||||
for (Conversation conversation : roomsOverall.getOcs().getData()) {
|
||||
if (roomId.equals(conversation.getRoomId())) {
|
||||
if (roomId.equals(conversation.getConversationId())) {
|
||||
currentConversation = conversation;
|
||||
runAllThings();
|
||||
break;
|
||||
|
@ -282,7 +282,7 @@ class ChatController(args: Bundle) : BaseController(), MessagesListAdapter
|
||||
|
||||
override fun onNext(roomsOverall: RoomsOverall) {
|
||||
for (conversation in roomsOverall.ocs.data) {
|
||||
if (roomId == conversation.roomId) {
|
||||
if (roomId == conversation.conversationId) {
|
||||
roomToken = conversation.token
|
||||
currentConversation = conversation
|
||||
setTitle()
|
||||
@ -519,7 +519,7 @@ class ChatController(args: Bundle) : BaseController(), MessagesListAdapter
|
||||
.nc_description_send_message_button
|
||||
)
|
||||
|
||||
if (currentConversation != null && currentConversation?.roomId != null) {
|
||||
if (currentConversation != null && currentConversation?.conversationId != null) {
|
||||
loadAvatarForStatusBar()
|
||||
checkLobbyState()
|
||||
setTitle()
|
||||
@ -1472,7 +1472,7 @@ class ChatController(args: Bundle) : BaseController(), MessagesListAdapter
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, conversationUser)
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs.data.token)
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs.data.roomId)
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs.data.conversationId)
|
||||
|
||||
if (conversationUser != null) {
|
||||
if (conversationUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
|
@ -308,7 +308,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(),
|
||||
roomOverall.getOcs().getData().getToken());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(),
|
||||
roomOverall.getOcs().getData().getRoomId());
|
||||
roomOverall.getOcs().getData().getConversationId());
|
||||
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
ncApi.getRoom(credentials,
|
||||
@ -903,7 +903,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(),
|
||||
roomOverall.getOcs().getData().getToken());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(),
|
||||
roomOverall.getOcs().getData().getRoomId());
|
||||
roomOverall.getOcs().getData().getConversationId());
|
||||
conversationIntent.putExtras(bundle);
|
||||
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
|
@ -652,7 +652,7 @@ public class OperationsMenuController extends BaseController {
|
||||
|
||||
Intent conversationIntent = new Intent(getActivity(), MagicCallActivity.class);
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), conversation.getToken());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), conversation.getRoomId());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), conversation.getConversationId());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_CONVERSATION_NAME(),
|
||||
conversation.getDisplayName());
|
||||
UserEntity conversationUser;
|
||||
|
@ -43,7 +43,7 @@ import org.parceler.Parcel;
|
||||
@JsonObject
|
||||
public class Conversation {
|
||||
@JsonField(name = "id")
|
||||
public String roomId;
|
||||
public String conversationId;
|
||||
@JsonField(name = "token")
|
||||
public String token;
|
||||
@JsonField(name = "name")
|
||||
|
@ -52,7 +52,7 @@ public class Participant {
|
||||
@JsonField(name = "sessionId")
|
||||
public String sessionId;
|
||||
|
||||
@JsonField(name = "roomId")
|
||||
@JsonField(name = "conversationId")
|
||||
public long roomId;
|
||||
|
||||
@ParcelPropertyConverter(ObjectParcelConverter.class)
|
||||
|
@ -33,6 +33,9 @@ class DeleteConversationUseCase constructor(
|
||||
|
||||
override suspend fun run(params: Any?): GenericOverall {
|
||||
val definitionParameters = params as DefinitionParameters
|
||||
return nextcloudTalkRepository.deleteConversationForUser(user, definitionParameters.get(0))
|
||||
return nextcloudTalkRepository.deleteConversationForUser(
|
||||
definitionParameters.get(0),
|
||||
definitionParameters.get(1)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import com.nextcloud.talk.newarch.data.source.remote.ApiErrorHandler
|
||||
import com.nextcloud.talk.newarch.domain.repository.NextcloudTalkRepository
|
||||
import com.nextcloud.talk.newarch.domain.usecases.base.UseCase
|
||||
import org.koin.core.parameter.DefinitionParameters
|
||||
|
||||
class GetConversationsUseCase constructor(
|
||||
private val nextcloudTalkRepository: NextcloudTalkRepository,
|
||||
@ -31,6 +32,6 @@ class GetConversationsUseCase constructor(
|
||||
) : UseCase<List<Conversation>, Any?>(apiErrorHandler) {
|
||||
|
||||
override suspend fun run(params: Any?): List<Conversation> {
|
||||
return nextcloudTalkRepository.getConversationsForUser(user)
|
||||
return nextcloudTalkRepository.getConversationsForUser((params as DefinitionParameters).get(0))
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ class LeaveConversationUseCase constructor(
|
||||
|
||||
override suspend fun run(params: Any?): GenericOverall {
|
||||
val definitionParameters = params as DefinitionParameters
|
||||
return nextcloudTalkRepository.leaveConversationForUser(user, definitionParameters.get(0))
|
||||
return nextcloudTalkRepository.leaveConversationForUser(
|
||||
definitionParameters.get(0),
|
||||
definitionParameters.get(1)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,10 @@ class SetConversationFavoriteValueUseCase constructor(
|
||||
|
||||
override suspend fun run(params: Any?): GenericOverall {
|
||||
val definitionParameters = params as DefinitionParameters
|
||||
return nextcloudTalkRepository.setFavoriteValueForConversation(user, definitionParameters.get(0), definitionParameters.get(1))
|
||||
return nextcloudTalkRepository.setFavoriteValueForConversation(
|
||||
definitionParameters.get(0),
|
||||
definitionParameters.get(1),
|
||||
definitionParameters.get(2)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
|
||||
package com.nextcloud.talk.newarch.domain.usecases.base
|
||||
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||
import com.nextcloud.talk.newarch.data.source.remote.ApiErrorHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.async
|
||||
@ -30,8 +28,6 @@ import kotlinx.coroutines.launch
|
||||
abstract class UseCase<Type, in Params>(private val apiErrorHandler: ApiErrorHandler?) where Type : Any {
|
||||
|
||||
abstract suspend fun run(params: Params? = null): Type
|
||||
lateinit var user: UserEntity
|
||||
fun isUserInitialized() = ::user.isInitialized
|
||||
|
||||
fun invoke(
|
||||
scope: CoroutineScope,
|
||||
|
@ -220,7 +220,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
||||
)
|
||||
) {
|
||||
view?.stateWithMessageView?.errorStateImageView?.setImageResource(
|
||||
drawable.ic_cloud_off_white_24dp
|
||||
drawable.ic_signal_wifi_off_white_24dp
|
||||
)
|
||||
} else {
|
||||
view?.stateWithMessageView?.errorStateImageView?.setImageResource(
|
||||
@ -396,7 +396,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, viewModel.currentUser)
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, conversation.token)
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, conversation.roomId)
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, conversation.conversationId)
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(conversation))
|
||||
ConductorRemapping.remapChatController(
|
||||
router, viewModel.currentUser.id, conversation.token,
|
||||
|
@ -49,6 +49,7 @@ import com.nextcloud.talk.newarch.domain.usecases.SetConversationFavoriteValueUs
|
||||
import com.nextcloud.talk.newarch.domain.usecases.base.UseCaseResponse
|
||||
import com.nextcloud.talk.newarch.utils.ViewState
|
||||
import com.nextcloud.talk.newarch.utils.ViewState.FAILED
|
||||
import com.nextcloud.talk.newarch.utils.ViewState.INITIAL_LOAD
|
||||
import com.nextcloud.talk.newarch.utils.ViewState.LOADED
|
||||
import com.nextcloud.talk.newarch.utils.ViewState.LOADED_EMPTY
|
||||
import com.nextcloud.talk.newarch.utils.ViewState.LOADING
|
||||
@ -70,7 +71,7 @@ class ConversationsListViewModel constructor(
|
||||
|
||||
private var conversations: MutableList<Conversation> = mutableListOf()
|
||||
val conversationsLiveListData = MutableLiveData<List<Conversation>>()
|
||||
val viewState = MutableLiveData<ViewState>(LOADING)
|
||||
val viewState = MutableLiveData<ViewState>(INITIAL_LOAD)
|
||||
var messageData: String? = null
|
||||
val searchQuery = MutableLiveData<String>()
|
||||
var currentUser: UserEntity = userUtils.currentUser
|
||||
@ -84,15 +85,13 @@ class ConversationsListViewModel constructor(
|
||||
}
|
||||
|
||||
fun leaveConversation(conversation: Conversation) {
|
||||
leaveConversationUseCase.user = currentUser
|
||||
|
||||
setConversationUpdateStatus(conversation, true)
|
||||
|
||||
leaveConversationUseCase.invoke(viewModelScope, parametersOf(conversation),
|
||||
leaveConversationUseCase.invoke(viewModelScope, parametersOf(currentUser, conversation),
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override fun onSuccess(result: GenericOverall) {
|
||||
// TODO: Use binary search to find the right room
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
conversations.find { it.conversationId == conversation.conversationId }
|
||||
?.let {
|
||||
conversations.remove(it)
|
||||
conversationsLiveListData.value = conversations
|
||||
@ -109,15 +108,13 @@ class ConversationsListViewModel constructor(
|
||||
}
|
||||
|
||||
fun deleteConversation(conversation: Conversation) {
|
||||
deleteConversationUseCase.user = currentUser
|
||||
|
||||
setConversationUpdateStatus(conversation, true)
|
||||
|
||||
deleteConversationUseCase.invoke(viewModelScope, parametersOf(conversation),
|
||||
deleteConversationUseCase.invoke(viewModelScope, parametersOf(currentUser, conversation),
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override fun onSuccess(result: GenericOverall) {
|
||||
// TODO: Use binary search to find the right room
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
conversations.find { it.conversationId == conversation.conversationId }
|
||||
?.let {
|
||||
conversations.remove(it)
|
||||
conversationsLiveListData.value = conversations
|
||||
@ -138,15 +135,17 @@ class ConversationsListViewModel constructor(
|
||||
conversation: Conversation,
|
||||
favorite: Boolean
|
||||
) {
|
||||
setConversationFavoriteValueUseCase.user = currentUser
|
||||
|
||||
setConversationUpdateStatus(conversation, true)
|
||||
|
||||
setConversationFavoriteValueUseCase.invoke(viewModelScope, parametersOf(conversation, favorite),
|
||||
setConversationFavoriteValueUseCase.invoke(viewModelScope, parametersOf(
|
||||
currentUser,
|
||||
conversation,
|
||||
favorite
|
||||
),
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override fun onSuccess(result: GenericOverall) {
|
||||
// TODO: Use binary search to find the right room
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
conversations.find { it.conversationId == conversation.conversationId }
|
||||
?.apply {
|
||||
updating = false
|
||||
isFavorite = favorite
|
||||
@ -161,17 +160,20 @@ class ConversationsListViewModel constructor(
|
||||
}
|
||||
|
||||
fun loadConversations() {
|
||||
currentUser = userUtils.currentUser
|
||||
val userChanged = !currentUser.equals(userUtils.currentUser)
|
||||
|
||||
if (userChanged) {
|
||||
currentUser = userUtils.currentUser
|
||||
}
|
||||
|
||||
if ((FAILED).equals(viewState.value) || (LOADED_EMPTY).equals(viewState.value) ||
|
||||
!getConversationsUseCase.isUserInitialized() || getConversationsUseCase.user != currentUser
|
||||
(INITIAL_LOAD).equals(viewState.value) || !currentUser.equals(userUtils.currentUser) || userChanged
|
||||
) {
|
||||
getConversationsUseCase.user = currentUser
|
||||
viewState.value = LOADING
|
||||
}
|
||||
|
||||
getConversationsUseCase.invoke(
|
||||
viewModelScope, null, object : UseCaseResponse<List<Conversation>> {
|
||||
viewModelScope, parametersOf(currentUser), object : UseCaseResponse<List<Conversation>> {
|
||||
override fun onSuccess(result: List<Conversation>) {
|
||||
val newConversations = result.toMutableList()
|
||||
|
||||
@ -232,7 +234,7 @@ class ConversationsListViewModel constructor(
|
||||
putExtra(
|
||||
Intent.EXTRA_SUBJECT,
|
||||
String.format(
|
||||
context.getString(R.string.nc_share_subject),
|
||||
context.getString(string.nc_share_subject),
|
||||
context.getString(R.string.nc_app_name)
|
||||
)
|
||||
)
|
||||
@ -248,9 +250,8 @@ class ConversationsListViewModel constructor(
|
||||
type = "text/plain"
|
||||
}
|
||||
|
||||
val intent = Intent.createChooser(sendIntent, context.getString(string.nc_share_link))
|
||||
// TODO filter our own app once we're there
|
||||
return intent
|
||||
return Intent.createChooser(sendIntent, context.getString(string.nc_share_link))
|
||||
}
|
||||
|
||||
fun getConversationMenuItemsForConversation(conversation: Conversation): MutableList<BasicListItemWithImage> {
|
||||
@ -307,7 +308,7 @@ class ConversationsListViewModel constructor(
|
||||
conversation: Conversation,
|
||||
value: Boolean
|
||||
) {
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
conversations.find { it.conversationId == conversation.conversationId }
|
||||
?.apply {
|
||||
updating = value
|
||||
conversationsLiveListData.value = conversations
|
||||
|
@ -21,8 +21,9 @@
|
||||
package com.nextcloud.talk.newarch.utils
|
||||
|
||||
enum class ViewState {
|
||||
INITIAL_LOAD,
|
||||
LOADING,
|
||||
LOADED_EMPTY,
|
||||
LOADED,
|
||||
FAILED
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user