Merge branch 'mkirk/cleanup-share-avatars'

This commit is contained in:
Michael Kirk 2018-05-10 11:33:22 -04:00
commit e520451996
3 changed files with 13 additions and 0 deletions

View file

@ -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;

View file

@ -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

View file

@ -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];
}