Merge b9d4a4ff8d into 584ce90b64
This commit is contained in:
commit
af0b2b563a
|
|
@ -75,6 +75,10 @@ import java.time.ZoneId
|
|||
class ChannelScreenViewModel(
|
||||
private val kvStorage: KVStorage,
|
||||
) : ViewModel() {
|
||||
private companion object {
|
||||
const val MAX_REPLY_TARGETS = 5
|
||||
}
|
||||
|
||||
var items = mutableStateListOf<ChannelScreenItem>()
|
||||
var typingUsers = mutableStateListOf<String>()
|
||||
|
||||
|
|
@ -353,7 +357,7 @@ class ChannelScreenViewModel(
|
|||
}
|
||||
|
||||
suspend fun addReplyTo(messageId: String) {
|
||||
if (draftReplyTo.size >= 5) return
|
||||
if (draftReplyTo.size >= MAX_REPLY_TARGETS) return
|
||||
if (draftReplyTo.any { it.id == messageId }) return
|
||||
|
||||
val shouldMention = kvStorage.getBoolean("mentionOnReply") ?: false
|
||||
|
|
@ -412,7 +416,7 @@ class ChannelScreenViewModel(
|
|||
// 2. if the user changes the content while the message is being sent we want to persist
|
||||
// the original content
|
||||
val content = MessageProcessor.processOutgoing(draftContent, channel?.server)
|
||||
val replyTo = draftReplyTo.toList()
|
||||
val replyTo = draftReplyTo.distinctBy { it.id }.take(MAX_REPLY_TARGETS)
|
||||
|
||||
// First we upload (the next 5) attachments...
|
||||
viewModelScope.launch {
|
||||
|
|
@ -818,13 +822,7 @@ class ChannelScreenViewModel(
|
|||
m is ChannelScreenItem.RegularMessage && m.message.id == it.messageId
|
||||
} as? ChannelScreenItem.RegularMessage ?: return@onEach
|
||||
|
||||
val shouldMention = kvStorage.getBoolean("mentionOnReply") ?: false
|
||||
draftReplyTo.add(
|
||||
SendMessageReply(
|
||||
message.message.id ?: return@onEach,
|
||||
shouldMention
|
||||
)
|
||||
)
|
||||
addReplyTo(message.message.id ?: return@onEach)
|
||||
}
|
||||
|
||||
is UiCallback.EditMessage -> {
|
||||
|
|
@ -843,13 +841,7 @@ class ChannelScreenViewModel(
|
|||
m is ChannelScreenItem.RegularMessage && m.message.id == it.messageId
|
||||
} as? ChannelScreenItem.RegularMessage ?: return@onEach
|
||||
|
||||
val shouldMention = kvStorage.getBoolean("mentionOnReply") ?: false
|
||||
draftReplyTo.add(
|
||||
SendMessageReply(
|
||||
message.message.id ?: return@onEach,
|
||||
shouldMention
|
||||
)
|
||||
)
|
||||
addReplyTo(message.message.id ?: return@onEach)
|
||||
putDraftContent(it.content, true)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue