mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Consolidate duplicated logic to retrieve groups in common.
Merges all of these into GroupsInCommonRepository: - ConversationSettingsRepository.getGroupsInCommon() - CallLinkIncomingRequestRepository.getGroupsInCommon() - ContactSearchPagedDataSourceRepository.getGroupsInCommon() - ReviewUtil.getGroupsInCommonCount() - AboutSheetRepository.getGroupsInCommonCount()
This commit is contained in:
committed by
Michelle Tang
parent
c9795141df
commit
aa7b61ecb1
@@ -12,12 +12,12 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeException;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager;
|
||||
import org.thoughtcrime.securesms.groups.GroupsInCommonRepository;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceMessageRequestResponseJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -57,7 +57,7 @@ class ReviewCardRepository {
|
||||
|
||||
@WorkerThread
|
||||
int loadGroupsInCommonCount(@NonNull ReviewRecipient reviewRecipient) {
|
||||
return ReviewUtil.getGroupsInCommonCount(context, reviewRecipient.getRecipient().getId());
|
||||
return GroupsInCommonRepository.getGroupsInCommonCountSync(reviewRecipient.getRecipient().getId());
|
||||
}
|
||||
|
||||
void block(@NonNull ReviewCard reviewCard, @NonNull Runnable onActionCompleteListener) {
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package org.thoughtcrime.securesms.profiles.spoofing;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.GroupRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
|
||||
public final class ReviewUtil {
|
||||
|
||||
private ReviewUtil() { }
|
||||
|
||||
@WorkerThread
|
||||
public static int getGroupsInCommonCount(@NonNull Context context, @NonNull RecipientId recipientId) {
|
||||
return Stream.of(SignalDatabase.groups()
|
||||
.getPushGroupsContainingMember(recipientId))
|
||||
.filter(g -> g.getMembers().contains(Recipient.self().getId()))
|
||||
.map(GroupRecord::getRecipientId)
|
||||
.toList()
|
||||
.size();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user