Fix illegal state exception during backup restore of unamed groups.
This commit is contained in:
parent
f7dce21246
commit
1547ec2067
2 changed files with 24 additions and 1 deletions
|
@ -6,6 +6,7 @@ import android.database.Cursor;
|
|||
|
||||
import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.ThreadUtil;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
|
@ -176,6 +177,28 @@ public final class LiveRecipientCache {
|
|||
return getLive(selfId).resolve();
|
||||
}
|
||||
|
||||
/** Can safely get self id. If used during early registration (backup), will return null as we don't know self yet. */
|
||||
@Nullable RecipientId getSelfId() {
|
||||
RecipientId selfId;
|
||||
|
||||
synchronized (localRecipientId) {
|
||||
selfId = localRecipientId.get();
|
||||
}
|
||||
|
||||
if (selfId != null) {
|
||||
return selfId;
|
||||
}
|
||||
|
||||
ACI localAci = SignalStore.account().getAci();
|
||||
String localE164 = SignalStore.account().getE164();
|
||||
|
||||
if (localAci == null && localE164 == null) {
|
||||
return null;
|
||||
} else {
|
||||
return getSelf().getId();
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public void warmUp() {
|
||||
if (warmedUp.getAndSet(true)) {
|
||||
|
|
|
@ -489,7 +489,7 @@ public class Recipient {
|
|||
|
||||
public @Nullable String getGroupName(@NonNull Context context) {
|
||||
if (groupId != null && Util.isEmpty(this.groupName)) {
|
||||
RecipientId selfId = Recipient.self().getId();
|
||||
RecipientId selfId = ApplicationDependencies.getRecipientCache().getSelfId();
|
||||
List<Recipient> others = participantIds.stream()
|
||||
.filter(id -> !id.equals(selfId))
|
||||
.limit(MAX_MEMBER_NAMES)
|
||||
|
|
Loading…
Add table
Reference in a new issue