mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 16:22:39 +00:00
Image attachment: improve image handling when table view is refreshed
This commit is contained in:
parent
7379459bdc
commit
a16f434be3
2 changed files with 13 additions and 11 deletions
|
@ -394,21 +394,20 @@
|
|||
}
|
||||
|
||||
- (void)setImageURL:(NSString *)anImageURL withPreviewImage:(UIImage*)previewImage {
|
||||
// the displayed image is already the expected one ?
|
||||
// Is the displayed image already the expected one ?
|
||||
if ([anImageURL isEqualToString:loadedImageURL]) {
|
||||
|
||||
// check if the image content has not been released
|
||||
if (self.image.size.width && self.image.size.height) {
|
||||
[self stopActivityIndicator];
|
||||
return;
|
||||
}
|
||||
|
||||
loadedImageURL = nil;
|
||||
}
|
||||
loadedImageURL = nil;
|
||||
|
||||
// the current image is already downloading
|
||||
// please wait....
|
||||
// it could be triggered after a screen rotation, new message ...
|
||||
if (anImageURL && [anImageURL isEqualToString:downloadingImageURL]) {
|
||||
// the current image is already downloading
|
||||
// please wait....
|
||||
// it could be triggered after a screen rotation, new message ...
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1280,11 +1280,9 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
isIncomingMsg = YES;
|
||||
}
|
||||
|
||||
// Restore initial settings
|
||||
// Keep reference on message
|
||||
cell.message = message;
|
||||
[cell.attachmentView setImageURL:nil withPreviewImage:nil]; // Cancel potential attachment loading
|
||||
cell.attachmentView.hidden = YES;
|
||||
cell.playIconView.hidden = YES;
|
||||
|
||||
// Remove all gesture recognizer
|
||||
while (cell.attachmentView.gestureRecognizers.count) {
|
||||
[cell.attachmentView removeGestureRecognizer:cell.attachmentView.gestureRecognizers[0]];
|
||||
|
@ -1376,6 +1374,8 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
NSString *url = message.thumbnailURL;
|
||||
if (message.messageType == RoomMessageTypeVideo) {
|
||||
cell.playIconView.hidden = NO;
|
||||
} else {
|
||||
cell.playIconView.hidden = YES;
|
||||
}
|
||||
|
||||
[cell.attachmentView setImageURL:url withPreviewImage:nil];
|
||||
|
@ -1396,6 +1396,9 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
// Adjust Attachment width constant
|
||||
cell.attachViewWidthConstraint.constant = contentSize.width;
|
||||
} else {
|
||||
[cell.attachmentView setImageURL:nil withPreviewImage:nil]; // Cancel potential attachment loading
|
||||
cell.attachmentView.hidden = YES;
|
||||
cell.playIconView.hidden = YES;
|
||||
cell.messageTextView.hidden = NO;
|
||||
if (!isIncomingMsg) {
|
||||
// Adjust horizontal position for outgoing messages (text is left aligned, but the textView should be right aligned)
|
||||
|
|
Loading…
Reference in a new issue