Skip to content

fix(android): can not open video in external app#4172

Merged
hyoban merged 1 commit into
devfrom
07-14-open-video-in-app
Jul 14, 2025
Merged

fix(android): can not open video in external app#4172
hyoban merged 1 commit into
devfrom
07-14-open-video-in-app

Conversation

@hyoban
Copy link
Copy Markdown
Member

@hyoban hyoban commented Jul 14, 2025

@hyoban hyoban requested a review from lawvs July 14, 2025 08:42
@claude
Copy link
Copy Markdown

claude Bot commented Jul 14, 2025

Claude finished @hyoban's task —— View job


PR Review: Android Video External App Fix

Review Summary

Approved with Minor Recommendations

This PR addresses a legitimate React Native issue where Linking.canOpenURL() can incorrectly return false for installed apps, preventing videos from opening in external players. The fix is well-targeted and follows the recommended React Native workaround.


Detailed Analysis

Code Quality & Best Practices

  • Clean implementation: The removal of the canOpenURL() check simplifies the logic appropriately
  • Consistent error handling: Still maintains proper try-catch around the URL opening
  • Good separation of concerns: The parseSchemeLink() function remains well-structured

Bug Fix Quality

  • Addresses root cause: Directly tackles the React Native issue (#32311) mentioned in the PR
  • Proper fallback logic: Maintains graceful degradation to in-app browser when scheme URLs fail
  • Sound logic change: The updated fallback URL handling (openLinksInExternalApp ? url : transformVideoUrl({ url }) || url) correctly applies transformations only for in-app viewing

Performance Impact

  • Positive improvement: Removes one async canOpenURL() call, reducing latency
  • No blocking operations: Maintains non-blocking behavior in the video opening flow

Security Considerations

  • No security risks: URL parsing and scheme validation remain intact
  • Safe error handling: Silent error catching prevents crashes without exposing sensitive information

⚠️ Areas of Concern

1. Test Coverage (Critical Gap)

apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx:128-145
  • No test coverage exists for this critical video functionality
  • Missing tests for openVideo(), parseSchemeLink(), and the component itself
  • This change affects user-facing behavior but has no automated verification

2. Error Handling Enhancement

// Consider adding user feedback for failed external app launches
} catch (error) {
  // Current: Silent failure
  // Suggestion: Optional user notification or analytics tracking
}

📋 Recommendations

High Priority:

  1. Add unit tests for the parseSchemeLink() function covering:

    • Valid YouTube/Bilibili URLs → correct schemes
    • Invalid URLs → null returns
    • Edge cases (malformed URLs, missing parameters)
  2. Add integration tests for openVideo() function testing:

    • External app opening with openLinksInExternalApp: true
    • In-app behavior with openLinksInExternalApp: false
    • Fallback behavior when scheme URLs fail

Medium Priority:
3. Consider user feedback for failed external app launches (optional)
4. Add analytics tracking for external app launch success/failure rates

🔧 Technical Notes

Final Verdict

This is a solid bug fix that addresses a real React Native limitation. The code changes are minimal, focused, and improve the user experience for Android video viewing. While test coverage is lacking, the fix itself is low-risk and follows established patterns.

Recommendation: Merge after considering test coverage improvements.


@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 14, 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 Jul 14, 2025 8:43am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
follow-external-ssr ⬜️ Ignored (Inspect) Jul 14, 2025 8:43am

Copy link
Copy Markdown
Contributor

@lawvs lawvs left a comment

Choose a reason for hiding this comment

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

Nice catch!

@hyoban hyoban merged commit 2c579c1 into dev Jul 14, 2025
11 of 12 checks passed
@hyoban hyoban deleted the 07-14-open-video-in-app branch July 14, 2025 08:55
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.

Open app with link Support opening the videos in Youtube App or Bilibili App on mobile

2 participants