Skip to content

feat(mobile): add option to open videos in external apps #2998

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

Merged
merged 6 commits into from
Mar 8, 2025

Conversation

lawvs
Copy link
Member

@lawvs lawvs commented Mar 7, 2025

Resolves FOL-1679

Introduce a setting to allow users to open YouTube and Bilibili videos in their respective apps instead of the in-app browser. This includes updates to settings management and video handling logic.

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
follow ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2025 5:35am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
follow-external-ssr ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2025 5:35am

Copy link

linear bot commented Mar 7, 2025

@follow-reviewer-bot
Copy link

Suggested PR Title:

feat(video): enable opening videos in external apps

Change Summary:
Added functionality to open videos in their respective apps instead of the in-app browser, along with new settings options and refactored video handling logic.

Code Review:

Code Review

1. File: apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx

  • Line 25: The slicing logic for item.media (item.media.slice(0, 1)) changes the original behavior of assigning the first media element (item.media[0]!). This change, although functional, introduces a different data structure (Array instead of a single object). It might lead to unintended consequences downstream, especially since MediaCarousel is receiving media={firstMedia}. If MediaCarousel expects only one media object for proper functioning, this change can result in broken behavior. Please verify and, if necessary, revert back to item.media[0]!.

2. File: packages/utils/src/url-for-video.ts

  • Line 10: The function URL.canParse(url) is used, but the standard JavaScript URL class does not have a canParse method. This will result in runtime errors. If this is a custom implementation or comes from a library, please ensure it is imported or documented. Otherwise, replace it with a proper URL validation technique.
  • Line 15: In the parseSchemeLink function, the direct use of new URL(url) without a preceding validation will throw an exception if an invalid URL is passed. Since the function does not guarantee url validity beforehand, wrap this in a try-catch block to handle potential errors gracefully.

3. File: packages/utils/src/url-for-video.ts

  • Line 28: In the case "www.bilibili.com" block, the bilibili://video/{bvid} scheme is constructed, but this implementation assumes all valid video paths will match the video/:id pattern. However, Bilibili URLs may have variations (e.g., additional query parameters or different path structures). A stricter regex pattern or additional fallback handling should be added to avoid issues.

Suggested Changes Summary:

  1. Ensure consistent data structure in EntryVideoItem.tsx when handling media.
  2. Address the absent URL.canParse method and validate URLs properly in url-for-video.ts.
  3. Add stricter regex handling and fallback support for Bilibili-specific URL parsing.

These changes are necessary to prevent runtime errors, unexpected behavior, and potential bugs when handling video URLs.

@lawvs lawvs force-pushed the feat/video-jump-app branch from cad56e9 to 6fae5f4 Compare March 8, 2025 05:33
@lawvs lawvs marked this pull request as ready for review March 8, 2025 05:33
@lawvs lawvs merged commit 4b0e13c into dev Mar 8, 2025
11 checks passed
@lawvs lawvs deleted the feat/video-jump-app branch March 8, 2025 06:00
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.

1 participant