Collapse KnownRecipient / Story into single model.

This commit is contained in:
Alex Hart
2023-01-18 10:49:47 -04:00
committed by Cody Henthorne
parent 70c6e9e60f
commit 8e313f8387
25 changed files with 93 additions and 137 deletions

View File

@@ -99,7 +99,7 @@ object SafetyNumberBottomSheet {
fun forIdentityRecordsAndDestinations(identityRecords: List<IdentityRecord>, destinations: List<ContactSearchKey>): Factory {
val args = SafetyNumberBottomSheetArgs(
identityRecords.map { it.recipientId },
destinations.filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireParcelable() }
destinations.filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireRecipientSearchKey() }
)
return SheetFactory(args)
@@ -115,7 +115,7 @@ object SafetyNumberBottomSheet {
fun forIdentityRecordsAndDestination(identityRecords: List<IdentityRecord>, destination: ContactSearchKey): Factory {
val args = SafetyNumberBottomSheetArgs(
identityRecords.map { it.recipientId },
listOf(destination).filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireParcelable() }
listOf(destination).filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireRecipientSearchKey() }
)
return SheetFactory(args)
@@ -131,14 +131,14 @@ object SafetyNumberBottomSheet {
return args!!
}
private fun getDestinationFromRecord(messageRecord: MessageRecord): List<ContactSearchKey.ParcelableRecipientSearchKey> {
private fun getDestinationFromRecord(messageRecord: MessageRecord): List<ContactSearchKey.RecipientSearchKey> {
val key = if ((messageRecord as? MmsMessageRecord)?.storyType?.isStory == true) {
ContactSearchKey.RecipientSearchKey.Story(messageRecord.recipient.id)
ContactSearchKey.RecipientSearchKey(messageRecord.recipient.id, true)
} else {
ContactSearchKey.RecipientSearchKey.KnownRecipient(messageRecord.recipient.id)
ContactSearchKey.RecipientSearchKey(messageRecord.recipient.id, false)
}
return listOf(key.requireParcelable())
return listOf(key)
}
/**

View File

@@ -12,6 +12,6 @@ import org.thoughtcrime.securesms.recipients.RecipientId
@Parcelize
data class SafetyNumberBottomSheetArgs(
val untrustedRecipients: List<RecipientId>,
val destinations: List<ContactSearchKey.ParcelableRecipientSearchKey>,
val destinations: List<ContactSearchKey.RecipientSearchKey>,
val messageId: MessageId? = null
) : Parcelable

View File

@@ -25,7 +25,7 @@ class SafetyNumberBottomSheetViewModel(
private const val MAX_RECIPIENTS_TO_DISPLAY = 5
}
private val destinationStore = RxStore(args.destinations.map { it.asRecipientSearchKey() })
private val destinationStore = RxStore(args.destinations)
val destinationSnapshot: List<ContactSearchKey.RecipientSearchKey>
get() = destinationStore.state