mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Update conversation header with group members.
This commit is contained in:
committed by
Cody Henthorne
parent
41e0f2193a
commit
da3fc408f8
@@ -1,5 +1,7 @@
|
||||
package org.thoughtcrime.securesms.messagerequests
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
/**
|
||||
* Group info needed to show message request state UX.
|
||||
*/
|
||||
@@ -7,7 +9,8 @@ class GroupInfo(
|
||||
val fullMemberCount: Int = 0,
|
||||
val pendingMemberCount: Int = 0,
|
||||
val description: String = "",
|
||||
val hasExistingContacts: Boolean = false
|
||||
val hasExistingContacts: Boolean = false,
|
||||
val membersPreview: List<Recipient> = emptyList()
|
||||
) {
|
||||
companion object {
|
||||
@JvmField
|
||||
|
||||
@@ -35,10 +35,12 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
@@ -49,6 +51,7 @@ public final class MessageRequestRepository {
|
||||
|
||||
private static final String TAG = Log.tag(MessageRequestRepository.class);
|
||||
private static final int MIN_GROUPS_THRESHOLD = 2;
|
||||
private static final int MAX_MEMBER_NAMES = 3;
|
||||
|
||||
private final Context context;
|
||||
private final Executor executor;
|
||||
@@ -65,20 +68,17 @@ public final class MessageRequestRepository {
|
||||
GroupInfo groupInfo = GroupInfo.ZERO;
|
||||
|
||||
if (groupRecord.isPresent()) {
|
||||
boolean groupHasExistingContacts = false;
|
||||
List<Recipient> recipients = Recipient.resolvedList(groupRecord.get().getMembers());
|
||||
if (groupRecord.get().isV2Group()) {
|
||||
List<Recipient> recipients = Recipient.resolvedList(groupRecord.get().getMembers());
|
||||
for (Recipient recipient : recipients) {
|
||||
if ((recipient.isProfileSharing() || recipient.isSystemContact()) && !recipient.isSelf()) {
|
||||
groupHasExistingContacts = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean groupHasExistingContacts = recipients.stream().filter(r -> !r.isSelf()).anyMatch(r -> r.isProfileSharing() || r.isSystemContact());
|
||||
List<Recipient> membersPreview = recipients.stream().filter(r -> !r.isSelf()).limit(MAX_MEMBER_NAMES).collect(Collectors.toList());
|
||||
DecryptedGroup decryptedGroup = groupRecord.get().requireV2GroupProperties().getDecryptedGroup();
|
||||
|
||||
DecryptedGroup decryptedGroup = groupRecord.get().requireV2GroupProperties().getDecryptedGroup();
|
||||
groupInfo = new GroupInfo(decryptedGroup.members.size(), decryptedGroup.pendingMembers.size(), decryptedGroup.description, groupHasExistingContacts);
|
||||
groupInfo = new GroupInfo(decryptedGroup.members.size(), decryptedGroup.pendingMembers.size(), decryptedGroup.description, groupHasExistingContacts, membersPreview);
|
||||
} else {
|
||||
groupInfo = new GroupInfo(groupRecord.get().getMembers().size(), 0, "", false);
|
||||
List<Recipient> membersPreview = recipients.stream().filter(r -> !r.isSelf()).limit(MAX_MEMBER_NAMES).collect(Collectors.toList());
|
||||
|
||||
groupInfo = new GroupInfo(groupRecord.get().getMembers().size(), 0, "", false, membersPreview);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user