Show message to user when trying to download two files from same message at the same time + fixed issue where second file download can't be started once the first one has finished
This commit is contained in:
parent
f07bc19d5f
commit
154659c083
5 changed files with 29 additions and 1 deletions
|
@ -98,6 +98,10 @@ class ChatMessagesListAdapter(
|
|||
MutableLiveData<Event<ChatMessage>>()
|
||||
}
|
||||
|
||||
val errorEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private val contentClickedListener = object : OnContentClickedListener {
|
||||
override fun onContentClicked(content: Content) {
|
||||
openContentEvent.value = Event(content)
|
||||
|
@ -110,6 +114,10 @@ class ChatMessagesListAdapter(
|
|||
override fun onCallConference(address: String, subject: String?) {
|
||||
callConferenceEvent.value = Event(Pair(address, subject))
|
||||
}
|
||||
|
||||
override fun onError(messageId: Int) {
|
||||
errorEvent.value = Event(messageId)
|
||||
}
|
||||
}
|
||||
|
||||
private var advancedContextMenuOptionsDisabled: Boolean = false
|
||||
|
|
|
@ -169,6 +169,12 @@ class ChatMessageContentData(
|
|||
}
|
||||
|
||||
fun download() {
|
||||
if (chatMessage.isFileTransferInProgress) {
|
||||
Log.w("[Content] Another FileTransfer content for this message is currently being downloaded, can't start another one for now")
|
||||
listener?.onError(R.string.chat_message_download_already_in_progress)
|
||||
return
|
||||
}
|
||||
|
||||
val content = getContent()
|
||||
val filePath = content.filePath
|
||||
if (content.isFileTransfer && (filePath == null || filePath.isEmpty())) {
|
||||
|
@ -179,7 +185,9 @@ class ChatMessageContentData(
|
|||
downloadEnabled.value = false
|
||||
|
||||
Log.i("[Content] Started downloading $contentName into ${content.filePath}")
|
||||
chatMessage.downloadContent(content)
|
||||
if (!chatMessage.downloadContent(content)) {
|
||||
Log.e("[Content] Failed to start content download!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -451,4 +459,6 @@ interface OnContentClickedListener {
|
|||
fun onSipAddressClicked(sipUri: String)
|
||||
|
||||
fun onCallConference(address: String, subject: String?)
|
||||
|
||||
fun onError(messageId: Int)
|
||||
}
|
||||
|
|
|
@ -539,6 +539,14 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
|
||||
adapter.errorEvent.observe(
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as MainActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
|
|
|
@ -623,4 +623,5 @@
|
|||
<string name="contacts_settings_ldap_debug_title">Débogage</string>
|
||||
<string name="contact_cant_be_deleted">Ce contact ne peut être supprimé</string>
|
||||
<string name="contacts_ldap_query_more_results_available">Plus de résultats sont disponibles, affinez votre recherche</string>
|
||||
<string name="chat_message_download_already_in_progress">Merci d\'attendre la fin du premier téléchargement avant d\'en lancer un second</string>
|
||||
</resources>
|
|
@ -228,6 +228,7 @@
|
|||
<string name="chat_message_removal_info">Message will be deleted</string>
|
||||
<string name="chat_message_abort_removal">Abort</string>
|
||||
<string name="chat_room_failed_to_create">Failed to create chat room</string>
|
||||
<string name="chat_message_download_already_in_progress">Please wait for first download to finish before starting a new one</string>
|
||||
|
||||
<!-- Recordings -->
|
||||
<string name="recordings_empty_list">No recordings</string>
|
||||
|
|
Loading…
Reference in a new issue