-
Notifications
You must be signed in to change notification settings - Fork 5
Fix synchronization issue with android notification #21
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
base: thomas/simplify-progress
Are you sure you want to change the base?
Fix synchronization issue with android notification #21
Conversation
| NoWifi, NoInternet, Ok; | ||
|
|
||
| companion object { | ||
| fun fetch(context: Context, wifiOnly: Boolean): Connectivity { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
elliottkember
left a comment
There was a problem hiding this 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++) { |
There was a problem hiding this comment.
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?
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
UploadNotificationsingleton and have it be aware of the active uploadNote
Moves notification config to a one-time Android initialize() and centralizes progress/connection UI via UploadNotification; updates worker logic and JS/TS types accordingly.
UploadNotificationsingleton to build/update a shared notification, track active upload, and handle titles based on connectivity.Connectivity.fetchfor validated internet/Wi‑Fi checks; remove inline connectivity logic fromUploadWorker.UploadWorkernow usesUploadNotificationfor foreground info and progress updates; removes per-upload notification building and validation helpers.MissingOptionExceptioninto its own class.Upload.UploaderModule.initialize(options)to set notification options.initialize(options: AndroidInitializationOptions);startUploadno longer acceptsandroidoptions.AndroidInitializationOptionstype; updateUploadOptionsand type declarations.Written by Cursor Bugbot for commit 99c0f34. Configure here.