robrix icon indicating copy to clipboard operation
robrix copied to clipboard

issues #81: Display link previews beneath a message containing a link

Open laonger opened this issue 11 months ago • 4 comments

Fixes #81 Remaining Issue:

1.	Due to the complexity of the page, many web pages cannot display the preview.
2.	The preview card requires scrolling the page to be displayed.

laonger avatar Feb 10 '25 07:02 laonger

You need to pass the ci first.

tyreseluo avatar Feb 27 '25 05:02 tyreseluo

You need to pass the ci first.

done

laonger avatar Feb 28 '25 05:02 laonger

One other issue, when there is more than one link, is the display of this card only one or, all of them, and when displaying too many cards, does it take up too much vertical space in the room_screen?

tyreseluo avatar Mar 04 '25 03:03 tyreseluo

  1. Other than that, I think our MatrixRequest could have been simpler.

we just need url to fetch the description, title and preview image.

MatrixRequest::FetchLinkPreview { url } => {
    let _fetch_task = Handle::current().spawn(async move {
        let preview_service = url_preview::PreviewService::with_no_cache();
        match preview_service.generate_preview(&url).await {
            Ok(preview) => {
                log!("preview data: {:?}", preview);
            },
            Err(e) => {
                log!("Failed to fetch link preview card for {url}: {e}");
            }
        };
    });
}

when we get the preview data, then we store to chace or use Cx::post_action(Some); pass the data to the widget

  1. We can use LinkPreview name to replace the Card name. also same to change the card_cache.

  2. It seems we don't need to change much of the code in room_screen, just handle it in html_or_plaintext.

you can see this PR #390

tyreseluo avatar Mar 11 '25 06:03 tyreseluo

The latest branch move to https://github.com/project-robius/robrix/pull/556

tyreseluo avatar Jul 30 '25 10:07 tyreseluo