mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 14:18:34 +00:00
Fix threading issues with LiveRecipient.
This commit is contained in:
parent
d354de806e
commit
8b99af3eef
@ -118,7 +118,7 @@ public final class LiveRecipient {
|
|||||||
* @return A fully-resolved version of the recipient. May require reading from disk.
|
* @return A fully-resolved version of the recipient. May require reading from disk.
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public synchronized @NonNull Recipient resolve() {
|
public @NonNull Recipient resolve() {
|
||||||
Recipient recipient = get();
|
Recipient recipient = get();
|
||||||
|
|
||||||
if (recipient.isResolving()) {
|
if (recipient.isResolving()) {
|
||||||
@ -134,7 +134,7 @@ public final class LiveRecipient {
|
|||||||
* Forces a reload of the underlying recipient.
|
* Forces a reload of the underlying recipient.
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public synchronized void refresh() {
|
public void refresh() {
|
||||||
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
||||||
liveData.postValue(recipient);
|
liveData.postValue(recipient);
|
||||||
Stream.of(recipient.getParticipants()).map(Recipient::live).forEach(LiveRecipient::refresh);
|
Stream.of(recipient.getParticipants()).map(Recipient::live).forEach(LiveRecipient::refresh);
|
||||||
|
@ -52,9 +52,11 @@ public final class LiveRecipientCache {
|
|||||||
return live;
|
return live;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized @NonNull Recipient getSelf() {
|
@NonNull Recipient getSelf() {
|
||||||
if (localRecipientId == null) {
|
synchronized (this) {
|
||||||
localRecipientId = recipientDatabase.getOrInsertFromE164(TextSecurePreferences.getLocalNumber(context));
|
if (localRecipientId == null) {
|
||||||
|
localRecipientId = recipientDatabase.getOrInsertFromE164(TextSecurePreferences.getLocalNumber(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getLive(localRecipientId).resolve();
|
return getLive(localRecipientId).resolve();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user