Added setting to prevent sending of multiple files in the same chat message until iOS app will be able to handle it

This commit is contained in:
Sylvain Berfini 2021-02-26 11:32:58 +01:00
parent ce6644dbee
commit d66c8bc44a
3 changed files with 13 additions and 2 deletions

View file

@ -109,6 +109,7 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
message.addUtf8TextContent(toSend)
}
var fileContent = false
for (attachment in attachments.value.orEmpty()) {
val content = Factory.instance().createContent()
@ -121,11 +122,14 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
content.name = attachment.fileName
content.filePath = attachment.path // Let the file body handler take care of the upload
if (isBasicChatRoom) {
// Do not send file in the same message as the text in a BasicChatRoom
// and don't send multiple files in the same message if setting says so
if (isBasicChatRoom or (corePreferences.preventMoreThanOneFilePerMessage and fileContent)) {
val fileMessage: ChatMessage = chatRoom.createFileTransferMessage(content)
fileMessage.send()
} else {
message.addFileContent(content)
fileContent = true
}
}

View file

@ -107,6 +107,13 @@ class CorePreferences constructor(private val context: Context) {
/* Chat */
// iOS app currently can't display more than 1 file per message
var preventMoreThanOneFilePerMessage: Boolean
get() = config.getBool("app", "prevent_more_than_one_file_per_message", true)
set(value) {
config.setBool("app", "prevent_more_than_one_file_per_message", value)
}
var markAsReadUponChatMessageNotificationDismissal: Boolean
get() = config.getBool("app", "mark_as_read_notif_dismissal", false)
set(value) {

View file

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.30'
ext.kotlin_version = '1.4.31'
repositories {
google()