Improve collapsed set selection.

This commit is contained in:
Michelle Tang
2026-04-13 12:42:09 -04:00
committed by jeffrey-signal
parent 69b6d7ef9a
commit 8306f8ec5b
2 changed files with 13 additions and 6 deletions

View File

@@ -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 }

View File

@@ -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()