-
Notifications
You must be signed in to change notification settings - Fork 40
Display link preview #585
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
Display link preview #585
Conversation
0a437e2 to
133d45b
Compare
kevinaboos
left a comment
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.
Very nice work!
It looks like we've migrated away from Alex's link preview crate, in favor of using the matrix homeserver's own link preview feature? I didn't know the homeserver offered that, so that's pretty cool to see.
I haven't yet reviewed the link_preview.rs widget code yet, but I wanted to give you some quick feedback here to avoid making you wait longer.
Two top-level questions:
- Can you test what happens when a message has multiple link previews? Based on the
populate_link_preview_below_message()function, I assume they will each be shown underneath each other, but I haven't tried it myself. Generally, we want to limit the number of link previews to a small number, maybe 3 maximum. We could also make that a user setting later, if desired. - Most importantly, we want to ensure that the timeline view doesn't jump around unexpectedly while the user is looking at it. In order to do that, we need to always show a placeholder view for the link preview even when the preview content itself is not yet available yet, or if the preview failed to load. That way, the height of the entire message view is always the same. I haven't checked if you've already done this, but please confirm that this behavior is followed or change the code to do so.
Kindly capture a screen recording showing what happens in the two above cases: multiple link previews in one message, and a consistent message view including a placeholder for a link preview that hasn't loaded yet or fails to load.
Here is the screen recording. |
Thanks for sharing the recording. So, the behavior around 0:05 - 0:06 is exactly what I was referring to when I wrote this:
You can see that the timeline jumps around a lot from 0:05 to 0:07 when the link previews actually load. What we need to do instead is to immediately (and always) show the link preview view if there are any links found in the message, rather than waiting for the preview to load before showing it. This will ensure that the timeline height is always the same for any message containing links. It also looks like there's too much vertical space beneath the link preview image/text: |
|
Fixed the height by 80. show the link preview view if there are any links, rather than waiting for preview. |
kevinaboos
left a comment
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.
Looks pretty good, just a few small comments.
There's a to-do item in the link_preview widget about using a TextOrImage widget, as well as something about the text not being displayed if the image is too small. Let me know what's going on there.
Co-authored-by: Kevin Boos <1139460+kevinaboos@users.noreply.github.com>
kevinaboos
left a comment
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 left some comments on the existing conversations.
997cde4 to
3a21baf
Compare
|
I noticed some UI jumping that appears to be caused when there is an error fetching the link preview. It looks like the link preview disappears (perhaps it's just hidden upon an error)... but let's not do that. Once we show the link preview, we must never hide it in order to keep the timeline UI stable. Here's a message with a link that failed to load the link preview: It looks like the response body wasn't parsed properly, i.e., you didn't expect that the EDIT: here's another example: |
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.
In addition to my above comment about not hiding link previews upon failure to fetch, here are some other minor issues/nitpicks that we should address now before merging this in.
- I think we should remove the vertical bar on the left of the link preview, because that makes it look like an inline reply preview or a quote, which might confuse the user.
- We need to ensure that the link preview's image is vertically centered with respect to the gray-background view. For example, this doesn't look very good because it's not centered:
- Add a bit of vertical margin to the top of the link preview, maybe just 3-5 pixels, such that it looks a bit cleaner. There's not much separation right now and it can be a bit hard to read. For example, the link preview almost collides/overlaps with the underlined link in this message:
- Please horizontally align the link preview title with the body text. In the above screenshot, "Introduction" and "Keyboard" should be left-aligned together.
- We could also consider using a different background color for links, instead of a light gray. Something like a light blue, light green, or light purple. You can experiment with a few options and see which one looks best.
- The "default image" i provided was just a suggestion. You can use it, but you probably need to crop the actual image file to remove the surrounding grayspace such that you don't need to pan/mask it when displaying it within an
Imagewidget.- I found a bunch of versions of that image here that you can choose from: https://www.aputf.org/wp-content/uploads/2015/06/
|
Added collapsible button
|
kevinaboos
left a comment
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.
Great work Alan, thanks so much!
Link previews were added in #585


Fixes #384Closes #81
Display link previews beneath a message containing a link.
https://github.com/user-attachments/assets/30f36549-f1d5-47e8-aa08-683eac1d1224