mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 16:19:33 +01:00
Display thread header in CFv2.
This commit is contained in:
committed by
Greyson Parrelli
parent
ffbbdc1576
commit
3ba128793a
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2023 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
package org.thoughtcrime.securesms.messagerequests
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
/**
|
||||
* Thread recipient and message request state information necessary to render
|
||||
* a thread header.
|
||||
*/
|
||||
data class MessageRequestRecipientInfo(
|
||||
val recipient: Recipient,
|
||||
val groupInfo: GroupInfo = GroupInfo.ZERO,
|
||||
val sharedGroups: List<String> = emptyList(),
|
||||
val messageRequestState: MessageRequestState? = null
|
||||
)
|
||||
@@ -72,6 +72,31 @@ public final class MessageRequestRepository {
|
||||
});
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public @NonNull MessageRequestRecipientInfo getRecipientInfo(@NonNull RecipientId recipientId, long threadId) {
|
||||
List<String> sharedGroups = SignalDatabase.groups().getPushGroupNamesContainingMember(recipientId);
|
||||
Optional<GroupRecord> groupRecord = SignalDatabase.groups().getGroup(recipientId);
|
||||
GroupInfo groupInfo = GroupInfo.ZERO;
|
||||
|
||||
if (groupRecord.isPresent()) {
|
||||
if (groupRecord.get().isV2Group()) {
|
||||
DecryptedGroup decryptedGroup = groupRecord.get().requireV2GroupProperties().getDecryptedGroup();
|
||||
groupInfo = new GroupInfo(decryptedGroup.getMembersCount(), decryptedGroup.getPendingMembersCount(), decryptedGroup.getDescription());
|
||||
} else {
|
||||
groupInfo = new GroupInfo(groupRecord.get().getMembers().size(), 0, "");
|
||||
}
|
||||
}
|
||||
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
return new MessageRequestRecipientInfo(
|
||||
recipient,
|
||||
groupInfo,
|
||||
sharedGroups,
|
||||
getMessageRequestState(recipient, threadId)
|
||||
);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public @NonNull MessageRequestState getMessageRequestState(@NonNull Recipient recipient, long threadId) {
|
||||
if (recipient.isBlocked()) {
|
||||
|
||||
Reference in New Issue
Block a user