Skip to content

Conversation

@thomasttvo
Copy link
Collaborator

@thomasttvo thomasttvo commented Oct 17, 2025

While a non-wifi-only upload is running and a wifi-only one is started but hasn't got its turn to run yet, it may still overwrite the shared notification with its own "wifiOnly" preferences.

This PR solves the problem by centralizing notification management into an UploadNotification singleton and have it be aware of the active upload


Note

Moves notification config to a one-time Android initialize() and centralizes progress/connection UI via UploadNotification; updates worker logic and JS/TS types accordingly.

  • Android (native):
    • Notification management: Introduce UploadNotification singleton to build/update a shared notification, track active upload, and handle titles based on connectivity.
    • Connectivity utility: Add Connectivity.fetch for validated internet/Wi‑Fi checks; remove inline connectivity logic from UploadWorker.
    • Worker changes: UploadWorker now uses UploadNotification for foreground info and progress updates; removes per-upload notification building and validation helpers.
    • Config errors: Extract MissingOptionException into its own class.
    • Model changes: Remove per-upload notification fields from Upload.
    • Module API: Add UploaderModule.initialize(options) to set notification options.
  • JS/TS API:
    • Add initialize(options: AndroidInitializationOptions); startUpload no longer accepts android options.
    • Add AndroidInitializationOptions type; update UploadOptions and type declarations.
  • Example app:
    • Initialize notifications once and demonstrate multiple concurrent uploads.

Written by Cursor Bugbot for commit 99c0f34. Configure here.

NoWifi, NoInternet, Ok;

companion object {
fun fetch(context: Context, wifiOnly: Boolean): Connectivity {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved from UploadWorker.ts no logical change

}

// builds the notification required to enable Foreground mode
fun build(context: Context): Notification {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved from UploadWorker.ts. Not much has changed except for val wifiOnly = getActiveUpload()?.wifiOnly ?: false

if (this.activeUpload?.id == upload.id) this.activeUpload = null
}

fun setOptions(opts: ReadableMap) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these options are moved over from the Upload class, so they are now global options instead of per-Upload options

Copy link

@elliottkember elliottkember left a comment

Choose a reason for hiding this comment

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

LGTM

setProgress(undefined);
console.log('Upload error!', err);
});
for (let i = 0; i < 100; i++) {

Choose a reason for hiding this comment

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

Can we add a comment explaining the magic number 100 and why we have to perform Upload.startUpload 100 times?

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.

4 participants