mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 02:18:34 +00:00
Refresh recipients outside of a transaction for storage service.
This commit is contained in:
parent
6704ad8193
commit
b6b499d865
@ -522,6 +522,7 @@ public class RecipientDatabase extends Database {
|
|||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
||||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||||
|
Set<RecipientId> needsRefresh = new HashSet<>();
|
||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
|
||||||
@ -556,7 +557,7 @@ public class RecipientDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
threadDatabase.setArchived(recipientId, insert.isArchived());
|
threadDatabase.setArchived(recipientId, insert.isArchived());
|
||||||
Recipient.live(recipientId).refresh();
|
needsRefresh.add(recipientId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,7 +599,7 @@ public class RecipientDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
threadDatabase.setArchived(recipientId, update.getNew().isArchived());
|
threadDatabase.setArchived(recipientId, update.getNew().isArchived());
|
||||||
Recipient.live(recipientId).refresh();
|
needsRefresh.add(recipientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SignalGroupV1Record insert : groupV1Inserts) {
|
for (SignalGroupV1Record insert : groupV1Inserts) {
|
||||||
@ -607,7 +608,7 @@ public class RecipientDatabase extends Database {
|
|||||||
Recipient recipient = Recipient.externalGroup(context, GroupId.v1orThrow(insert.getGroupId()));
|
Recipient recipient = Recipient.externalGroup(context, GroupId.v1orThrow(insert.getGroupId()));
|
||||||
|
|
||||||
threadDatabase.setArchived(recipient.getId(), insert.isArchived());
|
threadDatabase.setArchived(recipient.getId(), insert.isArchived());
|
||||||
recipient.live().refresh();
|
needsRefresh.add(recipient.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RecordUpdate<SignalGroupV1Record> update : groupV1Updates) {
|
for (RecordUpdate<SignalGroupV1Record> update : groupV1Updates) {
|
||||||
@ -621,7 +622,7 @@ public class RecipientDatabase extends Database {
|
|||||||
Recipient recipient = Recipient.externalGroup(context, GroupId.v1orThrow(update.getOld().getGroupId()));
|
Recipient recipient = Recipient.externalGroup(context, GroupId.v1orThrow(update.getOld().getGroupId()));
|
||||||
|
|
||||||
threadDatabase.setArchived(recipient.getId(), update.getNew().isArchived());
|
threadDatabase.setArchived(recipient.getId(), update.getNew().isArchived());
|
||||||
recipient.live().refresh();
|
needsRefresh.add(recipient.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SignalGroupV2Record insert : groupV2Inserts) {
|
for (SignalGroupV2Record insert : groupV2Inserts) {
|
||||||
@ -633,7 +634,7 @@ public class RecipientDatabase extends Database {
|
|||||||
ApplicationDependencies.getJobManager().add(new WakeGroupV2Job(insert.getMasterKey()));
|
ApplicationDependencies.getJobManager().add(new WakeGroupV2Job(insert.getMasterKey()));
|
||||||
|
|
||||||
threadDatabase.setArchived(recipient.getId(), insert.isArchived());
|
threadDatabase.setArchived(recipient.getId(), insert.isArchived());
|
||||||
recipient.live().refresh();
|
needsRefresh.add(recipient.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RecordUpdate<SignalGroupV2Record> update : groupV2Updates) {
|
for (RecordUpdate<SignalGroupV2Record> update : groupV2Updates) {
|
||||||
@ -647,13 +648,17 @@ public class RecipientDatabase extends Database {
|
|||||||
Recipient recipient = Recipient.externalGroup(context, GroupId.v2(update.getOld().getMasterKey()));
|
Recipient recipient = Recipient.externalGroup(context, GroupId.v2(update.getOld().getMasterKey()));
|
||||||
|
|
||||||
threadDatabase.setArchived(recipient.getId(), update.getNew().isArchived());
|
threadDatabase.setArchived(recipient.getId(), update.getNew().isArchived());
|
||||||
recipient.live().refresh();
|
needsRefresh.add(recipient.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (RecipientId id : needsRefresh) {
|
||||||
|
Recipient.live(id).refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyStorageSyncUpdates(@NonNull StorageId storageId, SignalAccountRecord update) {
|
public void applyStorageSyncUpdates(@NonNull StorageId storageId, SignalAccountRecord update) {
|
||||||
|
@ -14,12 +14,13 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
final class GroupsV2CapabilityChecker {
|
public final class GroupsV2CapabilityChecker {
|
||||||
|
|
||||||
private static final String TAG = Log.tag(GroupsV2CapabilityChecker.class);
|
private static final String TAG = Log.tag(GroupsV2CapabilityChecker.class);
|
||||||
|
|
||||||
GroupsV2CapabilityChecker() {
|
GroupsV2CapabilityChecker() {}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
boolean allAndSelfSupportGroupsV2AndUuid(@NonNull Collection<RecipientId> recipientIds)
|
boolean allAndSelfSupportGroupsV2AndUuid(@NonNull Collection<RecipientId> recipientIds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user