Fix failed reloads in SignalRecipient.

pull/1/head
Matthew Chen 7 years ago
parent 1e5a228c5b
commit 1c21c31c2b

@ -175,7 +175,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertDebug(devices.count > 0); OWSAssertDebug(devices.count > 0);
OWSLogDebug(@"removing devices: %@, from registered recipient: %@", devices, self); OWSLogDebug(@"removing devices: %@, from registered recipient: %@", devices, self);
[self reloadWithTransaction:transaction]; [self reloadWithTransaction:transaction ignoreMissing:YES];
[self removeDevices:devices]; [self removeDevices:devices];
[self saveWithTransaction_internal:transaction]; [self saveWithTransaction_internal:transaction];
} }

@ -94,8 +94,9 @@ NS_ASSUME_NONNULL_BEGIN
/** /**
* Assign the latest persisted values from the database. * Assign the latest persisted values from the database.
*/ */
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (void)reload; - (void)reload;
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction ignoreMissing:(BOOL)ignoreMissing;
/** /**
* Saves the object with the shared readWrite connection - does not block. * Saves the object with the shared readWrite connection - does not block.

@ -226,10 +226,17 @@ NS_ASSUME_NONNULL_BEGIN
} }
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction - (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction
{
[self reloadWithTransaction:transaction ignoreMissing:NO];
}
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction ignoreMissing:(BOOL)ignoreMissing
{ {
TSYapDatabaseObject *latest = [[self class] fetchObjectWithUniqueID:self.uniqueId transaction:transaction]; TSYapDatabaseObject *latest = [[self class] fetchObjectWithUniqueID:self.uniqueId transaction:transaction];
if (!latest) { if (!latest) {
OWSFailDebug(@"`latest` was unexpectedly nil"); if (!ignoreMissing) {
OWSFailDebug(@"`latest` was unexpectedly nil");
}
return; return;
} }

Loading…
Cancel
Save