Fix some timing issues around recipient events.
This commit is contained in:
parent
c2a6963a6d
commit
39709c8d64
2 changed files with 13 additions and 5 deletions
|
@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.R;
|
|||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||
import org.thoughtcrime.securesms.components.FromTextView;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
||||
import org.thoughtcrime.securesms.recipients.LiveRecipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
||||
|
@ -95,8 +96,9 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
|||
Recipient recipientSnapshot = recipient != null ? recipient.get() : null;
|
||||
|
||||
if (recipientSnapshot != null && !recipientSnapshot.isResolving()) {
|
||||
name = recipientSnapshot.getDisplayName(getContext());
|
||||
} else {
|
||||
contactName = recipientSnapshot.getDisplayName(getContext());
|
||||
name = contactName;
|
||||
} else if (recipient != null) {
|
||||
name = "";
|
||||
}
|
||||
|
||||
|
@ -212,6 +214,10 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
|||
@Override
|
||||
public void onRecipientChanged(@NonNull Recipient recipient) {
|
||||
if (this.recipient != null && this.recipient.getId().equals(recipient.getId())) {
|
||||
contactName = recipient.getDisplayName(getContext());
|
||||
contactAbout = recipient.getCombinedAboutAndEmoji();
|
||||
contactNumber = PhoneNumberFormatter.prettyPrint(recipient.getE164().or(""));
|
||||
|
||||
contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||
setText(recipient, contactType, contactName, contactNumber, contactLabel, contactAbout);
|
||||
smsTag.setVisibility(recipient.isRegistered() ? GONE : VISIBLE);
|
||||
|
|
|
@ -50,9 +50,11 @@ public final class LiveRecipient {
|
|||
this.groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
||||
this.observers = new CopyOnWriteArraySet<>();
|
||||
this.foreverObserver = recipient -> {
|
||||
for (RecipientForeverObserver o : observers) {
|
||||
o.onRecipientChanged(recipient);
|
||||
}
|
||||
ThreadUtil.postToMain(() -> {
|
||||
for (RecipientForeverObserver o : observers) {
|
||||
o.onRecipientChanged(recipient);
|
||||
}
|
||||
});
|
||||
};
|
||||
this.refreshForceNotify = new MutableLiveData<>(new Object());
|
||||
this.observableLiveData = LiveDataUtil.combineLatest(LiveDataUtil.distinctUntilChanged(liveData, Recipient::hasSameContent),
|
||||
|
|
Loading…
Add table
Reference in a new issue