Fix threading issues with LiveRecipient.

This commit is contained in:
Greyson Parrelli 2019-09-24 12:03:33 -04:00
parent d354de806e
commit 8b99af3eef
2 changed files with 7 additions and 5 deletions

View File

@ -118,7 +118,7 @@ public final class LiveRecipient {
* @return A fully-resolved version of the recipient. May require reading from disk.
*/
@WorkerThread
public synchronized @NonNull Recipient resolve() {
public @NonNull Recipient resolve() {
Recipient recipient = get();
if (recipient.isResolving()) {
@ -134,7 +134,7 @@ public final class LiveRecipient {
* Forces a reload of the underlying recipient.
*/
@WorkerThread
public synchronized void refresh() {
public void refresh() {
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
liveData.postValue(recipient);
Stream.of(recipient.getParticipants()).map(Recipient::live).forEach(LiveRecipient::refresh);

View File

@ -52,10 +52,12 @@ public final class LiveRecipientCache {
return live;
}
synchronized @NonNull Recipient getSelf() {
@NonNull Recipient getSelf() {
synchronized (this) {
if (localRecipientId == null) {
localRecipientId = recipientDatabase.getOrInsertFromE164(TextSecurePreferences.getLocalNumber(context));
}
}
return getLive(localRecipientId).resolve();
}