Skip to content

Commit

Permalink
feat(bootstrap): don't check for updates on loading screen
Browse files Browse the repository at this point in the history
  • Loading branch information
d-loose committed Apr 5, 2024
1 parent c7967e5 commit 3f5a9d6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
1 change: 0 additions & 1 deletion packages/ubuntu_bootstrap/lib/installer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ Future<void> _initInstallerApp(Endpoint endpoint) async {
final services = [
getService<InstallerService>().init(),
tryGetService<DesktopService>()?.inhibit() ?? Future.value(),
getService<RefreshService>().check(),
getService<PageConfigService>().load(),
geo.init(),
telemetry.init({
Expand Down
11 changes: 1 addition & 10 deletions packages/ubuntu_bootstrap/lib/installer/installer_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,25 @@ final restartProvider = StateProvider((_) => 0);
final installerModelProvider = ChangeNotifierProvider.autoDispose(
(_) => InstallerModel(
getService<InstallerService>(),
getService<RefreshService>(),
),
);

class InstallerModel extends SafeChangeNotifier {
InstallerModel(this._installer, this._refresh);
InstallerModel(this._installer);

final InstallerService _installer;
final RefreshService _refresh;

ApplicationStatus? _status;
StreamSubscription<ApplicationStatus?>? _statusChange;
StreamSubscription<RefreshState>? _refreshChange;

ApplicationStatus? get status => _status;
bool get isInstalling => status?.isInstalling ?? false;
bool get isRefreshing => _refresh.state.busy;

Future<void> init() async {
_statusChange = _installer.monitorStatus().listen((status) {
_status = status;
notifyListeners();
});
_refreshChange = _refresh.stateChanged.listen((_) {
notifyListeners();
});
}

bool hasRoute(String route) => _installer.hasRoute(route);
Expand All @@ -44,8 +37,6 @@ class InstallerModel extends SafeChangeNotifier {
Future<void> dispose() async {
await _statusChange?.cancel();
_statusChange = null;
await _refreshChange?.cancel();
_refreshChange = null;
super.dispose();
}
}
13 changes: 2 additions & 11 deletions packages/ubuntu_bootstrap/test/installer_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,31 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:subiquity_client/subiquity_client.dart';
import 'package:ubuntu_bootstrap/installer/installer_model.dart';
import 'package:ubuntu_bootstrap/services/refresh_service.dart';

import 'test_utils.dart';

void main() {
test('init', () async {
final statusController = StreamController<ApplicationStatus>();
final refreshController = StreamController<RefreshState>();

final installer = MockInstallerService();
when(installer.monitorStatus()).thenAnswer((_) => statusController.stream);

final refresh = MockRefreshService();
when(refresh.state).thenReturn(const RefreshState.checking());
when(refresh.stateChanged).thenAnswer((_) => refreshController.stream);

final model = InstallerModel(installer, refresh);
final model = InstallerModel(installer);
await model.init();
verify(installer.monitorStatus()).called(1);
expect(statusController.hasListener, isTrue);
verify(refresh.stateChanged).called(1);
expect(refreshController.hasListener, isTrue);

await model.dispose();
expect(statusController.hasListener, isFalse);
expect(refreshController.hasListener, isFalse);
});

test('has route', () async {
final installer = MockInstallerService();
when(installer.hasRoute('a')).thenReturn(true);
when(installer.hasRoute('b')).thenReturn(false);

final model = InstallerModel(installer, MockRefreshService());
final model = InstallerModel(installer);

expect(model.hasRoute('a'), isTrue);
expect(model.hasRoute('b'), isFalse);
Expand Down

0 comments on commit 3f5a9d6

Please sign in to comment.