mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 10:51:27 +01:00
Reduce number of db calls to getGroup.
This commit is contained in:
@@ -216,10 +216,10 @@ public final class LiveRecipient {
|
||||
avatarId = Optional.of(groupRecord.get().getAvatarId());
|
||||
}
|
||||
|
||||
return new RecipientDetails(title, null, avatarId, false, false, record.getRegistered(), record, members, false);
|
||||
return new RecipientDetails(title, null, avatarId, false, false, record.getRegistered(), record, members, false, groupRecord.get().isActive());
|
||||
}
|
||||
|
||||
return new RecipientDetails(null, null, Optional.empty(), false, false, record.getRegistered(), record, null, false);
|
||||
return new RecipientDetails(null, null, Optional.empty(), false, false, record.getRegistered(), record, null, false, false);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
||||
@@ -95,6 +95,7 @@ public class Recipient {
|
||||
private final DistributionListId distributionListId;
|
||||
private final List<RecipientId> participantIds;
|
||||
private final Optional<Long> groupAvatarId;
|
||||
private final boolean isActiveGroup;
|
||||
private final boolean isSelf;
|
||||
private final boolean blocked;
|
||||
private final long muteUntil;
|
||||
@@ -433,6 +434,7 @@ public class Recipient {
|
||||
this.badges = Collections.emptyList();
|
||||
this.isReleaseNotesRecipient = false;
|
||||
this.needsPniSignature = false;
|
||||
this.isActiveGroup = false;
|
||||
}
|
||||
|
||||
public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) {
|
||||
@@ -488,6 +490,7 @@ public class Recipient {
|
||||
this.badges = details.badges;
|
||||
this.isReleaseNotesRecipient = details.isReleaseChannel;
|
||||
this.needsPniSignature = details.needsPniSignature;
|
||||
this.isActiveGroup = details.isActiveGroup;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getId() {
|
||||
@@ -881,8 +884,14 @@ public class Recipient {
|
||||
}
|
||||
|
||||
public boolean isActiveGroup() {
|
||||
RecipientId selfId = Recipient.self().getId();
|
||||
return Stream.of(getParticipantIds()).anyMatch(p -> p.equals(selfId));
|
||||
return isActiveGroup;
|
||||
}
|
||||
|
||||
public boolean isUnknownGroup() {
|
||||
boolean noMetadata = (groupAvatarId.isEmpty() || groupAvatarId.get() == - 1) && (groupName == null || groupName.isEmpty());
|
||||
boolean noMembers = participantIds.isEmpty() || (participantIds.size() == 1 && participantIds.contains(Recipient.self().id));
|
||||
|
||||
return noMetadata && noMembers;
|
||||
}
|
||||
|
||||
public boolean isInactiveGroup() {
|
||||
|
||||
@@ -64,6 +64,7 @@ public class RecipientDetails {
|
||||
final ProfileAvatarFileDetails profileAvatarFileDetails;
|
||||
final boolean profileSharing;
|
||||
final boolean isHidden;
|
||||
final boolean isActiveGroup;
|
||||
final long lastProfileFetch;
|
||||
final boolean systemContact;
|
||||
final boolean isSelf;
|
||||
@@ -94,7 +95,8 @@ public class RecipientDetails {
|
||||
@NonNull RegisteredState registeredState,
|
||||
@NonNull RecipientRecord record,
|
||||
@Nullable List<RecipientId> participantIds,
|
||||
boolean isReleaseChannel)
|
||||
boolean isReleaseChannel,
|
||||
boolean isActiveGroup)
|
||||
{
|
||||
this.groupAvatarId = groupAvatarId;
|
||||
this.systemContactPhoto = Util.uri(record.getSystemContactPhotoUri());
|
||||
@@ -115,6 +117,7 @@ public class RecipientDetails {
|
||||
this.blocked = record.isBlocked();
|
||||
this.expireMessages = record.getExpireMessages();
|
||||
this.participantIds = participantIds == null ? new LinkedList<>() : participantIds;
|
||||
this.isActiveGroup = isActiveGroup;
|
||||
this.profileName = record.getProfileName();
|
||||
this.defaultSubscriptionId = record.getDefaultSubscriptionId();
|
||||
this.registered = registeredState;
|
||||
@@ -200,7 +203,8 @@ public class RecipientDetails {
|
||||
this.hasGroupsInCommon = false;
|
||||
this.badges = Collections.emptyList();
|
||||
this.isReleaseChannel = false;
|
||||
this.needsPniSignature = false;
|
||||
this.needsPniSignature = false;
|
||||
this.isActiveGroup = false;
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientRecord settings) {
|
||||
@@ -219,11 +223,11 @@ public class RecipientDetails {
|
||||
}
|
||||
}
|
||||
|
||||
return new RecipientDetails(null, settings.getSystemDisplayName(), Optional.empty(), systemContact, isSelf, registeredState, settings, null, isReleaseChannel);
|
||||
return new RecipientDetails(null, settings.getSystemDisplayName(), Optional.empty(), systemContact, isSelf, registeredState, settings, null, isReleaseChannel, false);
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forDistributionList(String title, @Nullable List<RecipientId> members, @NonNull RecipientRecord record) {
|
||||
return new RecipientDetails(title, null, Optional.empty(), false, false, record.getRegistered(), record, members, false);
|
||||
return new RecipientDetails(title, null, Optional.empty(), false, false, record.getRegistered(), record, members, false, false);
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forUnknown() {
|
||||
|
||||
Reference in New Issue
Block a user