-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add URL previews as a Labs feature #4790
Conversation
…ew model. Changes to RoomDataSource still to come.
Implement close button and store the action in Core Data. Hide the preview image view when no image is received. Remove line breaks in description text.
Make the preview manager a singleton (passing in the MXSession to functions). Fix tests. PreviewManager → URLPreviewManager URLPreviewViewData → URLPreviewData URLPreviewCache → URLPreviewStore
Using a temporary position in the settings screen whilst waiting for feedback.
📱 Scan the QR code below to install the build for this PR. If you can't scan the QR code you can install the build via this link: https://i.diawi.com/M4Lpog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Don't think the loading preview text is needed, there's a spinner already in there
-
The setting could say underneath the switch "will only show in unencrypted rooms" just to set that expectation
Update bubbleTableView's content offset when a preview above the bottom most visible cell changes the height of the table's content.
Rename store.store(_:) to store.cache(_:).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have context on a lot of the code so just picked out some general stuff. Looks great though.
|
||
import CoreData | ||
|
||
extension URLPreviewCacheData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we will have more Core Data entities which prefix or suffix we can use to distinguish the managed object from the memory object. A convention like CDURLPreviewData
for Core Data and URLPreviewData
for the memory representation?
NSURL *link = component.link; | ||
URLPreviewView *urlPreviewView; | ||
|
||
// Show a URL preview if the component has a link that should be previewed. | ||
if (link && RiotSettings.shared.roomScreenShowsURLPreviews && cellData.showURLPreview) | ||
{ | ||
urlPreviewView = [URLPreviewView instantiate]; | ||
urlPreviewView.preview = cellData.urlPreviewData; | ||
urlPreviewView.delegate = self; | ||
|
||
[temporaryViews addObject:urlPreviewView]; | ||
|
||
if (!bubbleCell.tmpSubviews) | ||
{ | ||
bubbleCell.tmpSubviews = [NSMutableArray array]; | ||
} | ||
[bubbleCell.tmpSubviews addObject:urlPreviewView]; | ||
|
||
urlPreviewView.translatesAutoresizingMaskIntoConstraints = NO; | ||
[bubbleCell.contentView addSubview:urlPreviewView]; | ||
|
||
CGFloat leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin; | ||
if (roomBubbleCellData.containsBubbleComponentWithEncryptionBadge) | ||
{ | ||
leftMargin+= RoomBubbleCellLayout.encryptedContentLeftMargin; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
start to become huge, it will be time to make intermediate methods and factorize some code. We can do it in another PR if needed.
if (RiotSettings.shared.roomScreenShowsURLPreviews && bubbleData && bubbleData.showURLPreview) | ||
{ | ||
CGFloat height = [super heightForCellData:cellData withMaximumWidth:maxWidth]; | ||
return height + RoomBubbleCellLayout.urlPreviewViewTopMargin + [URLPreviewView contentViewHeightFor:bubbleData.urlPreviewData]; | ||
} | ||
|
||
return [super heightForCellData:cellData withMaximumWidth:maxWidth]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a mechanism in RoomBubbleCellData
to compute the final height in - (void)addVerticalWhitespaceToString:(NSMutableAttributedString *)attributedString forEvent:(NSString *)eventId
. It can be weird to manipulate sizes in two different places.
This comment applies to all cell classes with a custom + (CGFloat)heightForCellData:(MXKCellData *)cellData withMaximumWidth:(CGFloat)maxWidth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that's so much neater! I really disliked doing this in the cells individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted this change for the current build as it doesn't automatically update when a preview changes from loading to loaded, and again from loaded to closed.
I don't want to hold back the release for this, so will look at it next.
URLPreviewManager becomes URLPreviewService. addVerticalWhitespaceToString used instead of heightForCellData multiple times. All newline characters removed.
URLPreviewCacheData becomes URLPreviewData in the model with a class name of URLPreviewDataMO ClosedURLData becomes URLPreviewUserData in the model with a class name of URLPreviewUserDataMO
Adds support for URL previews, fixing #888. Depends on matrix-org/matrix-ios-kit#893 and matrix-org/matrix-ios-sdk#1220.
urlPreviewData
property has been added toRoomBubbleCellData
which is filled with the preview data once fetched, along with ashowURLPreview
property to avoid having to hit Core Data too often.Updated: