Improve group name coloring performance.

This commit is contained in:
Cody Henthorne
2023-07-25 19:12:04 -04:00
committed by GitHub
parent ded29619cd
commit 3731723472
6 changed files with 75 additions and 20 deletions

View File

@@ -13,7 +13,8 @@ import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil
import org.whispersystems.signalservice.api.push.DistributionId
import java.lang.AssertionError
import org.whispersystems.signalservice.api.push.ServiceId
import org.whispersystems.signalservice.api.util.UuidUtil
import java.util.Optional
class GroupRecord(
@@ -44,6 +45,22 @@ class GroupRecord(
}
}
/** Valid for v2 groups only */
val decryptedMemberServiceIds: List<ServiceId> by lazy {
if (isV2Group) {
requireV2GroupProperties()
.decryptedGroup
.membersList
.asSequence()
.map { DecryptedGroupUtil.toUuid(it) }
.filterNot { it == UuidUtil.UNKNOWN_UUID }
.map { ServiceId.from(it) }
.toList()
} else {
emptyList()
}
}
/** V1 members that were lost during the V1->V2 migration */
val unmigratedV1Members: List<RecipientId> by lazy {
if (serializedUnmigratedV1Members.isNullOrEmpty()) {
@@ -183,4 +200,12 @@ class GroupRecord(
}
return false
}
fun hasSameMembers(other: GroupRecord): Boolean {
if (!isV2Group || !other.isV2Group) {
return false
}
return decryptedMemberServiceIds == other.decryptedMemberServiceIds
}
}