Display thread header in CFv2.

This commit is contained in:
Cody Henthorne
2023-05-11 15:39:59 -04:00
committed by Greyson Parrelli
parent ffbbdc1576
commit 3ba128793a
26 changed files with 235 additions and 49 deletions

View File

@@ -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
)

View File

@@ -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()) {