Skip to content

Commit

Permalink
Fix bug where adding attachment duplicates recipient count.
Browse files Browse the repository at this point in the history
  • Loading branch information
moxie0 committed Feb 23, 2014
1 parent 3dd27ed commit e80de7d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/org/thoughtcrime/securesms/components/RecipientsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
Expand All @@ -32,9 +33,11 @@
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
* Panel component combining both an editable field with a button for
Expand Down Expand Up @@ -79,12 +82,23 @@ public void addContacts(List<ContactAccessor.ContactData> contacts) {
}

public void addRecipients(Recipients recipients) {
Set<Recipient> panelRecipients;

try {
panelRecipients = new HashSet<Recipient>(getRecipients().getRecipientsList());
} catch (RecipientFormattingException e) {
Log.w("RecipientsPanel", e);
panelRecipients = new HashSet<Recipient>();
}

List<Recipient> recipientList = recipients.getRecipientsList();
Iterator<Recipient> iterator = recipientList.iterator();

while (iterator.hasNext()) {
Recipient recipient = iterator.next();
addRecipient(recipient.getName(), recipient.getNumber());
if (!panelRecipients.contains(recipient)) {
addRecipient(recipient.getName(), recipient.getNumber());
}
}
}

Expand Down

1 comment on commit e80de7d

@WhisperBTC
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! BitHub has sent payment of $13.29USD for this commit.

Please sign in to comment.