Skip to content

Chore: Refactor link previews and MediaView widget#1720

Merged
hjiangsu merged 4 commits intodevelopfrom
feat/refactor-media-view
Mar 3, 2025
Merged

Chore: Refactor link previews and MediaView widget#1720
hjiangsu merged 4 commits intodevelopfrom
feat/refactor-media-view

Conversation

@hjiangsu
Copy link
Copy Markdown
Member

@hjiangsu hjiangsu commented Mar 3, 2025

Pull Request Description

This PR is a continuation of the overall MediaView refactor - this time focusing on the MediaView widget and link previews. Here are some high level notes on the changes:

  • Removed LinkPreviewCard and replaced its usages with MediaView. LinkPreviewCard shared a lot of related logic with MediaView and made the code harder to follow. This led to some visual inconsistencies across link previews vs. image/video previews.
  • Started the deprecation of scrapeMissingPreviews option - I'm not sure how useful this option has been recently. In the past, there were issues with thumbnail generation which were mostly resolved in the backend. Having this option complicates the logic a bit, and has some potential performance issues as it has to fetch and parse through HTML content to find potential thumbnails (which should ideally be done at the backend regardless). That being said, do let me know if you feel strongly against this change!
  • Combined shared logic in MediaView together (e.g., shared container and box constraints) - this removes duplicated logic across the image/video widgets.
  • Removed dependency on PostViewMedia within MediaView. MediaView now only depends on a Media rather than the full PostViewMedia. This allows the widget to be more flexible and be used in places that don't have access to PostViewMedia (e.g., creating a new post with images)

This should more or less conclude the major refactors for MediaView, although there may be some smaller additional PRs to possibly split up/simplify the logic even more (if needed). Again, I did try to do as much testing as possible but there may be some bugs that were not caught during my testing, so please mention any issues that pop up!

This PR should also fix the issues mentioned here: #1715 (comment)!

Issue Being Fixed

Issue Number: N/A

Screenshots / Recordings

Checklist

  • If a new package was added, did you ensure it uses an appropriate license and is actively maintained?
  • Did you use localized strings (and added appropriate descriptions) where applicable?
  • Did you add semanticLabels where applicable for accessibility?

@micahmo
Copy link
Copy Markdown
Member

micahmo commented Mar 3, 2025

Started the deprecation of scrapeMissingPreviews option - I'm not sure how useful this option has been recently. In the past, there were issues with thumbnail generation which were mostly resolved in the backend. Having this option complicates the logic a bit, and has some potential performance issues as it has to fetch and parse through HTML content to find potential thumbnails (which should ideally be done at the backend regardless). That being said, do let me know if you feel strongly against this change!

I'm good with this! There are definitely still plenty of cases where Lemmy fails to find a thumbnail for the post, but these issues seem to be consistently reported to them and fixed by them. Plus users now have the option to add a custom thumbnail. So I don't see any reason for us to do additional work in this area.

Copy link
Copy Markdown
Member

@micahmo micahmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hjiangsu hjiangsu merged commit 25c0f45 into develop Mar 3, 2025
1 check passed
@hjiangsu hjiangsu deleted the feat/refactor-media-view branch March 3, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants