mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-27 14:45:01 +01:00
init other data earlier than ConversationModel
because setData was called too late (after sendTempChatMessages was called from messageInputFragment, internalConversationId was not initialized in repository). With this change, internalConversationId, credentials and urlForChatting are initialized earlier which should avoid the issue. However conversationModel is still initialized quite late and should be accessed with caution. This could may be improved by better architecture.. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
17702bbe92
commit
1bcdeb2d46
@ -440,10 +440,17 @@ class ChatActivity :
|
|||||||
conversationUser = currentUserProvider.currentUser.blockingGet()
|
conversationUser = currentUserProvider.currentUser.blockingGet()
|
||||||
handleIntent(intent)
|
handleIntent(intent)
|
||||||
|
|
||||||
messageInputFragment = getMessageInputFragment()
|
|
||||||
|
|
||||||
chatViewModel = ViewModelProvider(this, viewModelFactory)[ChatViewModel::class.java]
|
chatViewModel = ViewModelProvider(this, viewModelFactory)[ChatViewModel::class.java]
|
||||||
|
|
||||||
|
val urlForChatting = ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
||||||
|
val credentials = ApiUtils.getCredentials(conversationUser!!.username, conversationUser!!.token)
|
||||||
|
chatViewModel.initData(
|
||||||
|
credentials!!,
|
||||||
|
urlForChatting,
|
||||||
|
roomToken
|
||||||
|
)
|
||||||
|
|
||||||
|
messageInputFragment = getMessageInputFragment()
|
||||||
messageInputViewModel = ViewModelProvider(this, viewModelFactory)[MessageInputViewModel::class.java]
|
messageInputViewModel = ViewModelProvider(this, viewModelFactory)[MessageInputViewModel::class.java]
|
||||||
messageInputViewModel.setData(chatViewModel.getChatRepository())
|
messageInputViewModel.setData(chatViewModel.getChatRepository())
|
||||||
|
|
||||||
@ -576,14 +583,8 @@ class ChatActivity :
|
|||||||
chatViewModel.getConversationFlow
|
chatViewModel.getConversationFlow
|
||||||
.onEach { conversationModel ->
|
.onEach { conversationModel ->
|
||||||
currentConversation = conversationModel
|
currentConversation = conversationModel
|
||||||
|
chatViewModel.updateConversation(
|
||||||
val urlForChatting = ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
currentConversation!!
|
||||||
val credentials = ApiUtils.getCredentials(conversationUser!!.username, conversationUser!!.token)
|
|
||||||
|
|
||||||
chatViewModel.setData(
|
|
||||||
currentConversation!!,
|
|
||||||
credentials!!,
|
|
||||||
urlForChatting
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logConversationInfos("GetRoomSuccessState")
|
logConversationInfos("GetRoomSuccessState")
|
||||||
|
@ -44,7 +44,9 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
|||||||
|
|
||||||
val removeMessageFlow: Flow<ChatMessage>
|
val removeMessageFlow: Flow<ChatMessage>
|
||||||
|
|
||||||
fun setData(conversationModel: ConversationModel, credentials: String, urlForChatting: String)
|
fun initData(credentials: String, urlForChatting: String, roomToken: String)
|
||||||
|
|
||||||
|
fun updateConversation(conversationModel: ConversationModel)
|
||||||
|
|
||||||
fun initScopeAndLoadInitialMessages(withNetworkParams: Bundle)
|
fun initScopeAndLoadInitialMessages(withNetworkParams: Bundle)
|
||||||
|
|
||||||
|
@ -118,11 +118,14 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
private lateinit var credentials: String
|
private lateinit var credentials: String
|
||||||
private lateinit var urlForChatting: String
|
private lateinit var urlForChatting: String
|
||||||
|
|
||||||
override fun setData(conversationModel: ConversationModel, credentials: String, urlForChatting: String) {
|
override fun initData(credentials: String, urlForChatting: String, roomToken: String) {
|
||||||
this.conversationModel = conversationModel
|
internalConversationId = currentUser.id.toString() + "@" + roomToken
|
||||||
this.credentials = credentials
|
this.credentials = credentials
|
||||||
this.urlForChatting = urlForChatting
|
this.urlForChatting = urlForChatting
|
||||||
internalConversationId = conversationModel.internalId
|
}
|
||||||
|
|
||||||
|
override fun updateConversation(conversationModel: ConversationModel) {
|
||||||
|
this.conversationModel = conversationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initScopeAndLoadInitialMessages(withNetworkParams: Bundle) {
|
override fun initScopeAndLoadInitialMessages(withNetworkParams: Bundle) {
|
||||||
|
@ -243,8 +243,12 @@ class ChatViewModel @Inject constructor(
|
|||||||
val reactionDeletedViewState: LiveData<ViewState>
|
val reactionDeletedViewState: LiveData<ViewState>
|
||||||
get() = _reactionDeletedViewState
|
get() = _reactionDeletedViewState
|
||||||
|
|
||||||
fun setData(conversationModel: ConversationModel, credentials: String, urlForChatting: String) {
|
fun initData(credentials: String, urlForChatting: String, roomToken: String) {
|
||||||
chatRepository.setData(conversationModel, credentials, urlForChatting)
|
chatRepository.initData(credentials, urlForChatting, roomToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateConversation(currentConversation: ConversationModel) {
|
||||||
|
chatRepository.updateConversation(currentConversation)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoom(token: String) {
|
fun getRoom(token: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user