Reschedule media uploads when the Wi-Fi-only preference changes - #3946
Conversation
WorkManager constraints are immutable once a request is enqueued, so unchecking "Upload photos over Wi-Fi only" never applied to media uploads which had already been scheduled. Appending a new request left it blocked behind work still awaiting an unmetered connection, so pending photos were only uploaded once the device rejoined Wi-Fi. Replace pending media upload work when the preference changes so that the newly selected network type takes effect, and cancel it when local data is cleared, so that work left behind by a signed out user can't block uploads enqueued by the next one. Fixes #3945
|
Awesome! Thanks for the hyper-quick fix :) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3946 +/- ##
============================================
+ Coverage 69.99% 70.14% +0.15%
- Complexity 2033 2046 +13
============================================
Files 424 424
Lines 11647 11654 +7
Branches 1522 1524 +2
============================================
+ Hits 8152 8175 +23
+ Misses 2723 2708 -15
+ Partials 772 771 -1
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to reschedule or cancel pending media uploads in response to changes in the user's network preferences or when user data is cleared (e.g., during sign-out). This is achieved by updating MediaUploadWorkManager and integrating it into UserRepository, along with adding corresponding unit tests. The review feedback suggests a valuable optimization to rescheduleSyncWorker() to check for existing pending work before rescheduling, which avoids unnecessary WorkManager overhead when the queue is empty, and recommends updating the test suite to reflect this change.
Fixes #3945
WorkManager constraints are immutable once a request is enqueued, so unchecking "Upload photos over Wi-Fi only" never applied to media uploads which had already been scheduled. Appending a new request left it blocked behind work still awaiting an unmetered connection, so pending photos were only uploaded once the device rejoined Wi-Fi.
Replace pending media upload work when the preference changes so that the newly selected network type takes effect, and cancel it when local data is cleared, so that work left behind by a signed out user can't block uploads enqueued by the next one.
Also adds missing test coverage for the worker.
Screen_recording_20260916_222109.webm
@jo-spek @gino-m PTAL?