mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-03 23:15:44 +01:00
Improve collapsed set selection.
This commit is contained in:
committed by
jeffrey-signal
parent
69b6d7ef9a
commit
8306f8ec5b
@@ -310,13 +310,20 @@ class ConversationAdapterV2(
|
||||
if (multiselectPart.getMessageRecord().isInMemoryMessageRecord) { return }
|
||||
|
||||
if (multiselectPart is MultiselectPart.CollapsedHead) {
|
||||
val headId = multiselectPart.conversationMessage.messageRecord.collapsedHeadId
|
||||
val totalChildCount = multiselectPart.conversationMessage.collapsedSize - 1
|
||||
val collapsedChildren: List<MultiselectPart> = mutableListOf<MultiselectPart>().apply {
|
||||
add(getConversationMessage(adapterPosition)!!.multiselectCollection.asDouble().bottomPart)
|
||||
addAll(
|
||||
(1 until multiselectPart.conversationMessage.collapsedSize).mapNotNull { i ->
|
||||
getConversationMessage(adapterPosition - i)?.multiselectCollection?.asSingle()?.singlePart
|
||||
var currentChildCount = 0
|
||||
var offset = 1
|
||||
while (currentChildCount < totalChildCount && adapterPosition - offset >= 0) {
|
||||
val child = getConversationMessage(adapterPosition - offset)
|
||||
if (child != null && child.messageRecord.collapsedHeadId == headId) {
|
||||
add(child.multiselectCollection.asSingle().singlePart)
|
||||
currentChildCount++
|
||||
}
|
||||
)
|
||||
offset++
|
||||
}
|
||||
}
|
||||
|
||||
val isSelecting = collapsedChildren.any { it !in _selected }
|
||||
|
||||
@@ -3625,8 +3625,8 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
private fun getMessageDirectlyBefore(messageId: Long, threadId: Long, dateReceived: Long): PotentialCollapsibleMessage? {
|
||||
return readableDatabase
|
||||
.select(DATE_RECEIVED, TYPE, COLLAPSED_HEAD_ID, MESSAGE_EXTRAS)
|
||||
.from(TABLE_NAME)
|
||||
.where("$ID < ? AND $THREAD_ID = ?", messageId, threadId)
|
||||
.from("$TABLE_NAME INDEXED BY $INDEX_THREAD_STORY_SCHEDULED_DATE_LATEST_REVISION_ID")
|
||||
.where("$THREAD_ID = ? AND $DATE_RECEIVED < ?", threadId, dateReceived)
|
||||
.orderBy("$DATE_RECEIVED DESC")
|
||||
.limit(1)
|
||||
.run()
|
||||
|
||||
Reference in New Issue
Block a user