forked from upstream-mirrors/quik
simplify
This commit is contained in:
@@ -758,14 +758,10 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun showReactionsDialog(reactions: List<Pair<String, List<String>>>) {
|
||||
val message = reactions.flatMap { (emoji, contacts) ->
|
||||
contacts.map { "$emoji $it" }
|
||||
}.joinToString("\n")
|
||||
|
||||
override fun showReactionsDialog(reactions: List<String>) {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.compose_reactions_title)
|
||||
.setMessage(message)
|
||||
.setMessage(reactions.joinToString("\n"))
|
||||
.setPositiveButton(R.string.button_ok, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
fun showQksmsPlusSnackbar(@StringRes message: Int)
|
||||
fun showDeleteDialog( messages: List<Long>)
|
||||
fun showClearCurrentMessageDialog()
|
||||
fun showReactionsDialog(reactions: List<Pair<String, List<String>>>)
|
||||
fun showReactionsDialog(reactions: List<String>)
|
||||
fun startSpeechRecognition()
|
||||
fun focusMessage()
|
||||
}
|
||||
@@ -763,21 +763,15 @@ class ComposeViewModel @Inject constructor(
|
||||
view.reactionClickIntent
|
||||
.mapNotNull { messageId -> messageRepo.getMessage(messageId) }
|
||||
.withLatestFrom(conversation) { message, conv ->
|
||||
val reactions = message.emojiReactions
|
||||
.groupBy { it.emoji }
|
||||
.map { (emoji, emojiReactions) ->
|
||||
val contactNames = emojiReactions.map { reaction ->
|
||||
conv.recipients
|
||||
.firstOrNull { recipient ->
|
||||
phoneNumberUtils.compare(recipient.address, reaction.senderAddress)
|
||||
}
|
||||
?.getDisplayName()
|
||||
?: reaction.senderAddress
|
||||
message.emojiReactions.map { reaction ->
|
||||
val contactName = conv.recipients
|
||||
.firstOrNull { recipient ->
|
||||
phoneNumberUtils.compare(recipient.address, reaction.senderAddress)
|
||||
}
|
||||
emoji to contactNames
|
||||
}
|
||||
.sortedByDescending { it.second.size }
|
||||
reactions
|
||||
?.getDisplayName()
|
||||
?: reaction.senderAddress
|
||||
"${reaction.emoji} $contactName"
|
||||
}
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { reactions -> view.showReactionsDialog(reactions) }
|
||||
|
||||
Reference in New Issue
Block a user