configurable typing cues delay (#5437)
Co-authored-by: shuchi <shuchi.dwivedi@tesco.com>
This commit is contained in:
committed by
GitHub Enterprise
parent
1749fbf390
commit
7259faa67f
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2023 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.chat.models
|
||||
|
||||
data class ChatConfigConstructedResponse(
|
||||
val fileSizeInKB: HashMap<String, Int>?,
|
||||
val botTypingCuesDelayInMs: Long?
|
||||
)
|
||||
@@ -1,14 +1,17 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2022 by Navi Technologies Limited
|
||||
* * Copyright © 2022-2023 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.chat.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class ChatConfigResponse(
|
||||
val fileUpload: FileUpload?
|
||||
@SerializedName("fileUpload") val fileUpload: FileUpload? = null,
|
||||
@SerializedName("botTypingCuesDelayInMs") val botTypingCuesDelayInMs: Int? = null
|
||||
)
|
||||
|
||||
data class FileUpload(
|
||||
|
||||
@@ -98,6 +98,7 @@ class NaviChatFragment : ChatBaseFragment(), WidgetCallback, MessageOperation, T
|
||||
private var shouldShowChatResolutionWidget: Boolean = false
|
||||
private var csatWidgetData: NaviChatCsatRatingWidget? = null
|
||||
private var chatResolutionStatusWidget: NaviChatResolutionStatusWidget? = null
|
||||
private var delayForTypingCuesForBot = 1000L
|
||||
|
||||
@Inject lateinit var naviChatViewModel: NaviChatViewModel
|
||||
|
||||
@@ -340,7 +341,13 @@ class NaviChatFragment : ChatBaseFragment(), WidgetCallback, MessageOperation, T
|
||||
|
||||
naviChatViewModel.naviChatConfigResponse.observeNonNull(viewLifecycleOwner) {
|
||||
fileSizes.clear()
|
||||
fileSizes.putAll(it)
|
||||
it?.let {
|
||||
fileSizes.putAll(it.fileSizeInKB.orEmpty())
|
||||
it.botTypingCuesDelayInMs?.let { botDelayInMs ->
|
||||
delayForTypingCuesForBot = botDelayInMs
|
||||
Timber.d("Updated delayForTypingCuesForBot to $botDelayInMs")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
@@ -1002,7 +1009,7 @@ class NaviChatFragment : ChatBaseFragment(), WidgetCallback, MessageOperation, T
|
||||
widgetModel.rt_created_at
|
||||
)
|
||||
},
|
||||
DELAY_TO_HIDE_TYPING_FOR_BOT
|
||||
delayForTypingCuesForBot
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -1147,6 +1154,5 @@ class NaviChatFragment : ChatBaseFragment(), WidgetCallback, MessageOperation, T
|
||||
private const val DELAY_TO_SCROLL = 200L
|
||||
private const val RECYCLER_VIEW_BOOT_DELAY = 3000L
|
||||
private const val DELAY_TO_HIDE_TYPING = 10000L
|
||||
private const val DELAY_TO_HIDE_TYPING_FOR_BOT = 3000L
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.navi.base.utils.orZero
|
||||
import com.navi.chat.base.ChatBaseVM
|
||||
import com.navi.chat.db.utils.getDisplayableMessages
|
||||
import com.navi.chat.di.scopes.NaviChatScope
|
||||
import com.navi.chat.models.ChatConfigConstructedResponse
|
||||
import com.navi.chat.models.ChatConfigResponse
|
||||
import com.navi.chat.models.response.NaviChatInitiateResponse
|
||||
import com.navi.chat.repositories.NaviChatRepository
|
||||
@@ -50,8 +51,8 @@ constructor(private val naviChatRepository: NaviChatRepository, private val cont
|
||||
val chatHistoryMessages: LiveData<Pair<Int, List<NaviChatWidget>>>
|
||||
get() = _chatHistoryMessages
|
||||
|
||||
private val _naviChatConfigResponse = MutableLiveData<HashMap<String, Int>>()
|
||||
val naviChatConfigResponse: LiveData<HashMap<String, Int>>
|
||||
private val _naviChatConfigResponse = MutableLiveData<ChatConfigConstructedResponse?>()
|
||||
val naviChatConfigResponse: LiveData<ChatConfigConstructedResponse?>
|
||||
get() = _naviChatConfigResponse
|
||||
|
||||
private var _downloadSuccessSharedFlow = MutableSharedFlow<DownloadTask>(0)
|
||||
@@ -217,11 +218,20 @@ constructor(private val naviChatRepository: NaviChatRepository, private val cont
|
||||
response.data?.fileUpload.isNotNull() &&
|
||||
response.data?.fileUpload?.sizeInKiloBytes.isNotNull()
|
||||
) {
|
||||
_naviChatConfigResponse.value = response.data?.let { getHashMap(it) }
|
||||
_naviChatConfigResponse.value = response.data?.let {
|
||||
constructConfigResponse(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun constructConfigResponse(response: ChatConfigResponse): ChatConfigConstructedResponse? {
|
||||
return ChatConfigConstructedResponse(
|
||||
fileSizeInKB = getHashMap(response),
|
||||
botTypingCuesDelayInMs = response.botTypingCuesDelayInMs?.toLong() ?: 1000L
|
||||
)
|
||||
}
|
||||
|
||||
private fun getHashMap(response: ChatConfigResponse): HashMap<String, Int> {
|
||||
val hashmap = HashMap<String, Int>()
|
||||
response.fileUpload?.sizeInKiloBytes?.let { sizeInKb ->
|
||||
|
||||
Reference in New Issue
Block a user