Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Enable gradual rollout for resumable upload

Neeraj Gupta27f635dfaaf3
diff --git a/mobile/lib/ui/home/landing_page_widget.dart b/mobile/lib/ui/home/landing_page_widget.dart
index bdc1e8a03e..dda991b344 100644
--- a/mobile/lib/ui/home/landing_page_widget.dart
+++ b/mobile/lib/ui/home/landing_page_widget.dart
@@ -42,6 +42,10 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
void initState() {
super.initState();
Future(_showAutoLogoutDialogIfRequired);
+ Future.delayed(
+ const Duration(seconds: 1),
+ _autoEnableResumableUpload,
+ );
}
@override
@@ -304,6 +308,10 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
}
}
}
+
+ void _autoEnableResumableUpload() {
+ localSettings.autoEnableMultiplePart(20).ignore();
+ }
}
class FeatureItemWidget extends StatelessWidget {
diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dart
index 9ef36640b9..72bb8a2f1b 100644
--- a/mobile/lib/utils/local_settings.dart
+++ b/mobile/lib/utils/local_settings.dart
@@ -92,6 +92,18 @@ class LocalSettings {
bool get userEnabledMultiplePart =>
_prefs.getBool(kEnableMultiplePart) ?? false;
+ Future<void> autoEnableMultiplePart(int rolloutPercentage) async {
+ if (_prefs.containsKey(kEnableMultiplePart)) {
+ return;
+ }
+ rolloutPercentage = rolloutPercentage.clamp(0, 100);
+ final randomValue = DateTime.now().millisecondsSinceEpoch % 100;
+ await _prefs.setBool(
+ kEnableMultiplePart,
+ randomValue < rolloutPercentage,
+ );
+ }
+
Future<bool> setUserEnabledMultiplePart(bool value) async {
await _prefs.setBool(kEnableMultiplePart, value);
return value;