π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Keep device health decisions current
Neeraj Guptae0206b4ddafe
diff --git a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dartindex b62ee09961..36d588330f 100644--- a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart+++ b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart@@ -24,6 +24,7 @@ class ComputeController {// ignore: cancel_subscriptionsStreamSubscription<DeviceHealthSnapshot>? _deviceHealthSubscription;Timer? _deviceHealthRefreshTimer;+ int _deviceHealthGeneration = 0;bool _isDeviceHealthy = false;bool _isUserInteracting = true;@@ -273,17 +274,23 @@ class ComputeController {}Future<void> _refreshDeviceHealth() async {+ final generation = _deviceHealthGeneration;try {final snapshot = await _deviceHealthSource.getSnapshot().timeout(_healthRequestTimeout,);- _onDeviceHealthUpdate(snapshot);+ if (generation == _deviceHealthGeneration) {+ _onDeviceHealthUpdate(snapshot);+ }} catch (error, stackTrace) {- _onDeviceHealthError(error, stackTrace);+ if (generation == _deviceHealthGeneration) {+ _onDeviceHealthError(error, stackTrace);+ }}}void _onDeviceHealthUpdate(DeviceHealthSnapshot snapshot) {+ _deviceHealthGeneration++;final evaluation = _deviceHealthPolicy.evaluate(snapshot,now: DateTime.now(),@@ -298,6 +305,7 @@ class ComputeController {}void _onDeviceHealthError(Object error, [StackTrace? stackTrace]) {+ _deviceHealthGeneration++;_logger.warning('Failed to observe device health', error, stackTrace);_setDeviceHealth(false);_fireControlEvent();