Skip to content

Commit

Permalink
Remove concept of 'unknown' recipient.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 8, 2019
1 parent 89c2329 commit 9447ea1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void set(@NonNull GlideRequests glideRequests,

if (type == ContactRepository.NEW_TYPE) {
this.recipient = null;
this.contactPhotoImage.setAvatar(glideRequests, Recipient.UNKNOWN, false);
this.contactPhotoImage.setAvatar(glideRequests, null, false);
} else if (recipientId != null) {
this.recipient = Recipient.live(recipientId);
this.recipient.observeForever(this);
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/database/MmsDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ private SlideDeck getSlideDeck(@NonNull List<DatabaseAttachment> attachments) {
List<? extends Attachment> quoteAttachments = Stream.of(attachments).filter(Attachment::isQuote).toList();
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);

if (quoteId > 0 && !quoteAuthor.isUnknown()) {
if (quoteId > 0) {
return new Quote(quoteId, quoteAuthor, quoteText, quoteMissing, quoteDeck);
} else {
return null;
Expand Down
9 changes: 5 additions & 4 deletions src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,12 @@ private void storeRetrievedMms(String contentLocation,
String body = null;
List<Attachment> attachments = new LinkedList<>();

RecipientId from;
RecipientId from = null;

if (retrieved.getFrom() != null) {
from = Recipient.external(context, Util.toIsoString(retrieved.getFrom().getTextString())).getId();
} else if (notificationFrom != null) {
from = notificationFrom;
} else {
from = RecipientId.UNKNOWN;
}

if (retrieved.getTo() != null) {
Expand All @@ -211,7 +209,10 @@ private void storeRetrievedMms(String contentLocation,
}
}

members.add(from);
if (from != null) {
members.add(from);
}

members.add(Recipient.self().getId());

if (retrieved.getBody() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public final class LiveRecipientCache {
private final Context context;
private final RecipientDatabase recipientDatabase;
private final Map<RecipientId, LiveRecipient> recipients;
private final LiveRecipient unknown;

private RecipientId localRecipientId;

Expand All @@ -32,13 +31,10 @@ public LiveRecipientCache(@NonNull Context context) {
this.context = context.getApplicationContext();
this.recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
this.recipients = new LRUCache<>(1000);
this.unknown = new LiveRecipient(context, new MutableLiveData<>(), Recipient.UNKNOWN);
}

@AnyThread
synchronized @NonNull LiveRecipient getLive(@NonNull RecipientId id) {
if (id.isUnknown()) return unknown;

LiveRecipient live = recipients.get(id);

if (live == null) {
Expand Down
2 changes: 0 additions & 2 deletions src/org/thoughtcrime/securesms/recipients/Recipient.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

public class Recipient {

public static final Recipient UNKNOWN = new Recipient(RecipientId.UNKNOWN);

private final RecipientId id;
private final boolean resolving;
private final Address address;
Expand Down
7 changes: 0 additions & 7 deletions src/org/thoughtcrime/securesms/recipients/RecipientId.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@

public class RecipientId implements Parcelable, Comparable<RecipientId> {

private static final long UNKNOWN_ID = -1;
private static final char DELIMITER = ',';

public static final RecipientId UNKNOWN = RecipientId.from(UNKNOWN_ID);

private final long id;

public static RecipientId from(long id) {
Expand Down Expand Up @@ -54,10 +51,6 @@ public static List<RecipientId> fromSerializedList(@NonNull String serialized) {
return out;
}

public boolean isUnknown() {
return id == UNKNOWN_ID;
}

public @NonNull String serialize() {
return String.valueOf(id);
}
Expand Down

0 comments on commit 9447ea1

Please sign in to comment.