diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index d6175c719..d01f821f4 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -181,34 +181,12 @@ if (localImage) { // we did not load the image yet, so start doing so if (_messageImageView.image == nil) { - [_messageImageView startLoading]; - PHFetchResult *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil]; - UIImage *img = nil; - - img = [chatTableView.imagesInChatroom objectForKey:localImage]; - if (![assets firstObject]) - [self loadPlaceholder]; - PHAsset *asset = [assets firstObject]; - if (img) - [self loadImageAsset:asset image:img]; - else - [self loadAsset:asset]; + [self loadFirstImage:localImage type:PHAssetMediaTypeImage]; } } else if (localVideo) { if (_messageImageView.image == nil) { - [_messageImageView startLoading]; - PHFetchResult *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localVideo] options:nil]; - UIImage *img = nil; - - img = [chatTableView.imagesInChatroom objectForKey:localVideo]; - if (![assets firstObject]) - [self loadPlaceholder]; - PHAsset *asset = [assets firstObject]; - if (img) - [self loadImageAsset:asset image:img]; - else - [self loadAsset:asset]; + [self loadFirstImage:localVideo type:PHAssetMediaTypeVideo]; } } else if (localFile) { @@ -236,8 +214,25 @@ } } +- (void)loadFirstImage:(NSString *)key type:(PHAssetMediaType)type { + [_messageImageView startLoading]; + PHFetchResult *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:key] options:nil]; + UIImage *img = nil; + + img = [chatTableView.imagesInChatroom objectForKey:key]; + PHAsset *asset = [assets firstObject]; + if (!asset) + [self loadPlaceholder]; + else if (asset.mediaType == type) + img = nil; + if (img) + [self loadImageAsset:asset image:img]; + else + [self loadAsset:asset]; +} + - (void)fileErrorBlock { - DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Can't open this file", nil)]; + DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Can't find this file", nil)]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [sheet addCancelButtonWithTitle:NSLocalizedString(@"OK", nil) block:nil]; dispatch_async(dispatch_get_main_queue(), ^{ diff --git a/Classes/Utils/FileTransferDelegate.m b/Classes/Utils/FileTransferDelegate.m index 532fea218..4b2fd6915 100644 --- a/Classes/Utils/FileTransferDelegate.m +++ b/Classes/Utils/FileTransferDelegate.m @@ -270,6 +270,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m linphone_iphone_file_transfer_send); // internal url is saved in the appdata for display and later save + LOGE(@"nnnn %@ %@",key, keyData); [LinphoneManager setValueInMessageAppData:keyData forKey:key inMessage:_message]; [LinphoneManager setValueInMessageAppData:qualityData forKey:@"uploadQuality" inMessage:_message]; @@ -291,7 +292,10 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m - (void)uploadVideo:(NSData *)data withassetId:(NSString *)phAssetId forChatRoom:(LinphoneChatRoom *)chatRoom { NSString *name = [NSString stringWithFormat:@"IMG-%f.MOV", [NSDate timeIntervalSinceReferenceDate]]; - [self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localvideo" keyData:phAssetId qualityData:nil]; + if (phAssetId) + [self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localvideo" keyData:phAssetId qualityData:nil]; + else + [self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localvideo" keyData:@"ending..." qualityData:nil]; } - (void)uploadFile:(NSData *)data forChatRoom:(LinphoneChatRoom *)chatRoom withName:(NSString *)name {