Merge branch 'charlesmchen/groupAvatarUpdates'

This commit is contained in:
Matthew Chen 2018-05-18 16:17:03 -04:00
commit a7aaa7f6be
4 changed files with 19 additions and 9 deletions

View file

@ -3835,6 +3835,8 @@ typedef enum : NSUInteger {
[message updateWithCustomMessage:updateGroupInfo transaction:transaction];
}];
[groupThread fireAvatarChangedNotification];
if (newGroupModel.groupImage) {
NSData *data = UIImagePNGRepresentation(newGroupModel.groupImage);
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"];

View file

@ -129,7 +129,7 @@ public class ConversationAvatarImageView: AvatarImageView {
func handleGroupAvatarChanged(notification: Notification) {
Logger.debug("\(self.logTag) in \(#function)")
guard let changedGroupThreadId = notification.userInfo?[TSGroupThread_NotificaitonKey_UniqueId] as? String else {
guard let changedGroupThreadId = notification.userInfo?[TSGroupThread_NotificationKey_UniqueId] as? String else {
owsFail("\(logTag) in \(#function) groupThreadId was unexpectedly nil")
return
}

View file

@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@class YapDatabaseReadWriteTransaction;
extern NSString *const TSGroupThreadAvatarChangedNotification;
extern NSString *const TSGroupThread_NotificaitonKey_UniqueId;
extern NSString *const TSGroupThread_NotificationKey_UniqueId;
@interface TSGroupThread : TSThread
@ -37,6 +37,8 @@ extern NSString *const TSGroupThread_NotificaitonKey_UniqueId;
- (void)updateAvatarWithAttachmentStream:(TSAttachmentStream *)attachmentStream
transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)fireAvatarChangedNotification;
@end
NS_ASSUME_NONNULL_END

View file

@ -13,7 +13,7 @@
NS_ASSUME_NONNULL_BEGIN
NSString *const TSGroupThreadAvatarChangedNotification = @"TSGroupThreadAvatarChangedNotification";
NSString *const TSGroupThread_NotificaitonKey_UniqueId = @"TSGroupThread_NotificaitonKey_UniqueId";
NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_NotificationKey_UniqueId";
@implementation TSGroupThread
@ -197,12 +197,7 @@ NSString *const TSGroupThread_NotificaitonKey_UniqueId = @"TSGroupThread_Notific
[transaction addCompletionQueue:nil
completionBlock:^{
NSDictionary *userInfo = @{ TSGroupThread_NotificaitonKey_UniqueId : self.uniqueId };
[[NSNotificationCenter defaultCenter]
postNotificationName:TSGroupThreadAvatarChangedNotification
object:self.uniqueId
userInfo:userInfo];
[self fireAvatarChangedNotification];
}];
// Avatars are stored directly in the database, so there's no need
@ -210,6 +205,17 @@ NSString *const TSGroupThread_NotificaitonKey_UniqueId = @"TSGroupThread_Notific
[attachmentStream removeWithTransaction:transaction];
}
- (void)fireAvatarChangedNotification
{
OWSAssertIsOnMainThread();
NSDictionary *userInfo = @{ TSGroupThread_NotificationKey_UniqueId : self.uniqueId };
[[NSNotificationCenter defaultCenter] postNotificationName:TSGroupThreadAvatarChangedNotification
object:self.uniqueId
userInfo:userInfo];
}
@end
NS_ASSUME_NONNULL_END