diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index a904efbdc..d99e00fff 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -334,6 +334,7 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)setComposingVisible:(BOOL)visible withDelay:(CGFloat)delay { + Boolean shouldAnimate = composingVisible == visible; CGRect keyboardFrame = [_messageView frame]; CGRect newComposingFrame = [_composeIndicatorView frame]; CGRect newTableFrame = [_tableController.tableView frame]; @@ -364,8 +365,10 @@ static UICompositeViewDescription *compositeDescription = nil; composingVisible = visible; [UIView animateWithDuration:delay animations:^{ - _tableController.tableView.frame = newTableFrame; - _composeIndicatorView.frame = newComposingFrame; + if (shouldAnimate) + return; + _tableController.tableView.frame = newTableFrame; + _composeIndicatorView.frame = newComposingFrame; } completion:^(BOOL finished) { [_tableController scrollToBottom:TRUE]; diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index c7b3cda28..3bdb3bdfa 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -85,6 +85,17 @@ [super setChatMessage:amessage]; } +- (void) loadAsset:(ALAsset*) asset { + UIImage *image = [[UIImage alloc] initWithCGImage:[asset thumbnail]]; + dispatch_async(dispatch_get_main_queue(), ^{ + [_messageImageView setImage:image]; + [_messageImageView setFullImageUrl:asset]; + [_messageImageView stopLoading]; + _messageImageView.hidden = NO; + _imageGestureRecognizer.enabled = YES; + }); +} + - (void)update { if (self.message == nil) { LOGW(@"Cannot update message room cell: NULL message"); @@ -113,16 +124,27 @@ resultBlock:^(ALAsset *asset) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) { - if (achat == self.message) { // Avoid glitch and scrolling - UIImage *image = [[UIImage alloc] initWithCGImage:[asset thumbnail]]; - dispatch_async(dispatch_get_main_queue(), ^{ - [_messageImageView setImage:image]; - [_messageImageView setFullImageUrl:asset]; - [_messageImageView stopLoading]; - _messageImageView.hidden = NO; - _imageGestureRecognizer.enabled = YES; - }); - } + if (achat != self.message) // Avoid glitch and scrolling + return; + + if (asset) + [self loadAsset:asset]; + else { + [LinphoneManager.instance.photoLibrary + enumerateGroupsWithTypes:ALAssetsGroupAll + usingBlock:^(ALAssetsGroup *group, BOOL *stop) { + [group enumerateAssetsWithOptions:NSEnumerationReverse + usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { + if([result.defaultRepresentation.url isEqual:imageUrl]) { + [self loadAsset:result]; + *stop = YES; + } + }]; + } + failureBlock:^(NSError *error) { + LOGE(@"Error: Cannot load asset from photo stream - %@", [error localizedDescription]); + }]; + } }); } failureBlock:^(NSError *error) {