Merge branch 'mkirk/cleanup-share-avatars'

pull/1/head
Michael Kirk 7 years ago
commit e520451996

@ -117,6 +117,8 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value);
@property (nonatomic, readonly, nullable) NSString *avatarAttachmentId;
- (nullable TSAttachment *)avatarAttachmentWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (void)removeAvatarAttachmentWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)saveAvatarImage:(UIImage *)image transaction:(YapDatabaseReadWriteTransaction *)transaction;
// "Profile" avatars should _not_ be saved to device contacts.
@property (nonatomic, readonly) BOOL isProfileAvatar;

@ -499,6 +499,13 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
self.avatarAttachmentId = attachmentStream.uniqueId;
}
- (void)removeAvatarAttachmentWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
TSAttachmentStream *_Nullable attachment =
[TSAttachmentStream fetchObjectWithUniqueID:self.avatarAttachmentId transaction:transaction];
[attachment removeWithTransaction:transaction];
}
#pragma mark - Phone Numbers and Recipient IDs
- (NSArray<NSString *> *)systemContactsWithSignalAccountPhoneNumbers:(id<ContactsManagerProtocol>)contactsManager

@ -289,6 +289,10 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
[attachment removeWithTransaction:transaction];
};
if (self.contactShare.avatarAttachmentId) {
[self.contactShare removeAvatarAttachmentWithTransaction:transaction];
}
// Updates inbox thread preview
[self touchThreadWithTransaction:transaction];
}

Loading…
Cancel
Save