Skip to content

feat: add download support and bridge to React Native - #2

Closed
syed-tp wants to merge 2 commits into
mainfrom
feat/expose_download_module
Closed

feat: add download support and bridge to React Native#2
syed-tp wants to merge 2 commits into
mainfrom
feat/expose_download_module

Conversation

@syed-tp

@syed-tp syed-tp commented Jun 17, 2025

Copy link
Copy Markdown
Contributor
  • Upgrade tpstreams-player version to 0.0.8
  • Add TPStreamsDownloadModule native module for Android
  • Bridge download functionality to React Native
  • Expose download methods
  • Add TypeScript interfaces for DownloadItem
  • Export download module and types from main package

Summary by CodeRabbit

  • New Features
    • Introduced download management functionality, allowing users to view, pause, resume, and cancel downloads, as well as check download status and completion for videos.
  • Chores
    • Updated a library dependency to a newer version for improved compatibility.

@codetortoiseai

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 17, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new download management feature for TPStreams was introduced, including native Android and React Native module implementations. The Android build configuration was updated to use a newer player library version. The new functionality exposes download operations and status queries to the JavaScript layer, with corresponding TypeScript types and exports.

Changes

File(s) Change Summary
android/build.gradle Updated "com.tpstreams:tpstreams-player" dependency from version 0.0.6 to 0.0.8.
android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt Added a new React Native module for Android exposing download management methods to JS.
android/src/main/java/com/tpstreams/TPStreamsRNPackage.kt Registered the new TPStreamsDownloadModule with the React Native package.
src/TPStreamsDownload.tsx Added TypeScript interface and methods to interact with the native download module via React Native bridge.
src/index.tsx Exported the new download module and its type from the main entry point.

Sequence Diagram(s)

sequenceDiagram
  participant JS as JavaScript (TPStreamsDownload)
  participant RN as React Native Bridge
  participant Native as TPStreamsDownloadModule (Android)
  participant Tracker as DownloadTracker

  JS->>RN: getDownloads()
  RN->>Native: getDownloads(promise)
  Native->>Tracker: fetchDownloads()
  Tracker-->>Native: List<DownloadItem>
  Native-->>RN: resolve(promise, downloads)
  RN-->>JS: Promise resolves with downloads

  JS->>RN: pauseDownload(videoId)
  RN->>Native: pauseDownload(videoId, promise)
  Native->>Tracker: pause(videoId)
  Tracker-->>Native: success/failure
  Native-->>RN: resolve/reject(promise)
  RN-->>JS: Promise resolves with result
Loading

Poem

A hop and a skip, now downloads abound,
With modules and bridges, new features are found.
From Kotlin to TypeScript, the code flows with ease,
Managing your streams, however you please.
With paws on the keyboard, this bunny’s elated—
TPStreams downloads are now integrated!
🐇✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai

coderabbitai Bot commented Jun 17, 2025

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
src/index.tsx (1)

10-12: Re-export looks fine – double-check tree shaking

Nothing blocking, but note that wildcard re-exports alongside a default export may prevent treeshaking in consumer bundles if they import * from your package.
If bundle size is a concern, consider a namespaced export instead.

src/TPStreamsDownload.tsx (1)

16-40: Wrap native calls with type guards

A rejected promise from native will propagate an untyped error. Wrapping the calls lets you normalise the error shape for TS consumers:

-  getDownloads(): Promise<DownloadItem[]> {
-    return TPStreamsDownload.getDownloads();
-  },
+  async getDownloads(): Promise<DownloadItem[]> {
+    try {
+      return await TPStreamsDownload.getDownloads();
+    } catch (e: any) {
+      throw new Error(e?.message ?? 'Failed to fetch downloads');
+    }
+  },

Replicate for the other methods if you want unified error handling.

android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt (1)

14-21: RuntimeException on init will crash the app

Throwing inside a lazy delegate bubbles up during the first JS call, crashing the whole RN process.
Prefer rejecting the individual promise instead, or at least log & return a non-fatal error.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91ce4fd and f64d34d.

📒 Files selected for processing (5)
  • android/build.gradle (1 hunks)
  • android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt (1 hunks)
  • android/src/main/java/com/tpstreams/TPStreamsRNPackage.kt (1 hunks)
  • src/TPStreamsDownload.tsx (1 hunks)
  • src/index.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-ios
  • GitHub Check: build-android
🔇 Additional comments (2)
android/build.gradle (1)

84-88: Confirm artefact availability for bumped player version 0.0.8

The version bump is straightforward, but the custom Maven repo (TPStreamsAndroidPlayerMaven) occasionally lags behind public tags. A missing artefact will break the Gradle sync at consumer apps.

#!/bin/bash
# Sanity-check that the pom for 0.0.8 exists in the custom repo
curl -s -o /dev/null -w "%{http_code}\n" \
  https://raw.githubusercontent.com/testpress/TPStreamsAndroidPlayerMaven/main/repo/com/tpstreams/tpstreams-player/0.0.8/tpstreams-player-0.0.8.pom

The script should return 200. Any other status means the artefact is not yet published.

android/src/main/java/com/tpstreams/TPStreamsRNPackage.kt (1)

16-20: Module list update looks good

TPStreamsDownloadModule is now exposed to JS. No duplicate names detected. 👍

Comment thread src/TPStreamsDownload.tsx
Comment thread android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt
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