@@ -15,6 +15,7 @@ import com.flipcash.app.permissions.PickedContact
1515import com.flipcash.app.phone.PhoneUtils
1616import com.flipcash.app.tokens.TokenCoordinator
1717import com.flipcash.features.directsend.R
18+ import com.flipcash.services.models.chat.ChatMember
1819import com.flipcash.services.models.chat.ChatType
1920import com.flipcash.services.models.chat.MessageContent
2021import com.flipcash.services.user.UserManager
@@ -228,7 +229,11 @@ internal class SendFlowViewModel @Inject constructor(
228229 chatFeed : List <ChatSummary >,
229230 tokensByMint : Map <Mint , Token >,
230231 ): List <ContactListItem > = buildList {
231- val allContacts = contactState.contacts.values.toList()
232+ val selfId = userManager.accountId
233+ val selfPhone = userManager.profile?.verifiedPhoneNumber
234+
235+ val allContacts = contactState.contacts.values
236+ .filter { selfPhone == null || it.e164 != selfPhone }
232237 val filtered = if (searchString.isBlank()) {
233238 allContacts
234239 } else {
@@ -238,8 +243,6 @@ internal class SendFlowViewModel @Inject constructor(
238243 }
239244 }
240245
241- val selfId = userManager.accountId
242-
243246 val dmChats = chatFeed.filter { it.metadata.type == ChatType .DM }
244247 // Build a reverse lookup: e164 -> chatId string for contacts with DMs
245248 val e164ToChatId = contactState.dmChatIds
@@ -253,7 +256,9 @@ internal class SendFlowViewModel @Inject constructor(
253256 // Try to match this chat to a device contact
254257 val e164 = e164ToChatId.entries
255258 .firstOrNull { it.value == chatIdStr }?.key
256- val deviceContact = e164?.let { contactState.contacts[it] }
259+ val deviceContact = e164
260+ ?.takeIf { selfPhone == null || it != selfPhone }
261+ ?.let { contactState.contacts[it] }
257262
258263 val contact = if (deviceContact != null ) {
259264 if (searchString.isNotBlank() &&
@@ -265,8 +270,11 @@ internal class SendFlowViewModel @Inject constructor(
265270 deviceContact
266271 } else {
267272 // Non-contact DM — build contact from chat member profile
273+ val isSelf = { member: ChatMember ->
274+ member.userId == selfId || (selfPhone != null && member.userProfile.verifiedPhoneNumber == selfPhone)
275+ }
268276 val otherMember = summary.metadata.members
269- .firstOrNull { it.userId != selfId } ? : return @mapNotNull null
277+ .firstOrNull { ! isSelf(it) } ? : return @mapNotNull null
270278 val phone = otherMember.userProfile.verifiedPhoneNumber
271279 val formattedPhone = phone?.let { phoneUtils.formatNumber(it) }
272280 val displayName = otherMember.userProfile.displayName?.takeIf { it.isNotBlank() }
@@ -304,19 +312,14 @@ internal class SendFlowViewModel @Inject constructor(
304312 .sortedWith(compareBy(String .CASE_INSENSITIVE_ORDER ) { it.displayName })
305313 .map { ContactListItem .ContactRow (contact = it, isOnFlipcash = true ) }
306314
315+ val flipcashCombined = (recentRows + flipcashRows)
316+
307317 val excludedE164s = recentsE164s + contactState.flipcashE164s
308318 val other = filtered
309319 .filter { it.e164 !in excludedE164s }
310320 .sortedWith(compareBy(String .CASE_INSENSITIVE_ORDER ) { it.displayName })
311321
312- if (recentRows.isNotEmpty()) {
313- add(ContactListItem .Header (resources.getString(R .string.title_recents)))
314- addAll(recentRows)
315- }
316- if (flipcashRows.isNotEmpty()) {
317- add(ContactListItem .Header (resources.getString(R .string.title_flipcashContacts)))
318- addAll(flipcashRows)
319- }
322+ addAll(flipcashCombined)
320323 if (other.isNotEmpty()) {
321324 add(ContactListItem .Header (resources.getString(R .string.title_nonFlipcashContacts)))
322325 other.forEach { add(ContactListItem .ContactRow (it, isOnFlipcash = false )) }
0 commit comments