Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Jun 10, 2024
1 parent 9ab3501 commit fc97c07
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/domain/connection/connection_state_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ class ConnectionCallbacksStateNotifier
void dispose() {
ConnectionCallbacks.setup(null);
_connectionControl.cancelObservingConnectionChanges();
super.dispose();
//XXX: Potentially a bug in riverpod
if (mounted) {
super.dispose();
}
}
}

final AutoDisposeStateNotifierProvider<ConnectionCallbacksStateNotifier, WatchConnectionState>
connectionStateProvider =
StateNotifierProvider.autoDispose<ConnectionCallbacksStateNotifier, WatchConnectionState>((ref) {
final notifier = ConnectionCallbacksStateNotifier();
ref.onDispose(notifier.dispose);
ref.onDispose(() {
if (notifier.mounted) {
notifier.dispose();
}
});
return notifier;
});
8 changes: 8 additions & 0 deletions test/fakes/fake_permissions_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class FakePermissionCheck implements PermissionCheck {
bool reportedCalendarPermission = true;
bool reportedLocationPermission = true;
bool reportedNotificationAccess = true;
bool reportedCallsAccess = true;

@override
Future<BooleanWrapper> hasBatteryExclusionEnabled() {
Expand Down Expand Up @@ -33,4 +34,11 @@ class FakePermissionCheck implements PermissionCheck {
wrapper.value = reportedNotificationAccess;
return Future.value(wrapper);
}

@override
Future<BooleanWrapper> hasCallsPermissions() {
final wrapper = BooleanWrapper();
wrapper.value = reportedCallsAccess;
return Future.value(wrapper);
}
}

0 comments on commit fc97c07

Please sign in to comment.