diff --git a/lib/src/detail/detail_page.dart b/lib/src/detail/detail_page.dart index 547449dda..16e0bbafa 100644 --- a/lib/src/detail/detail_page.dart +++ b/lib/src/detail/detail_page.dart @@ -348,11 +348,11 @@ enum SnapAction { VoidCallback? callback(SnapModel model, [SnapLauncher? launcher]) => switch (this) { cancel => model.cancel, - install => model.install, + install => model.storeSnap != null ? model.install : null, open => launcher?.isLaunchable ?? false ? launcher!.open : null, remove => model.remove, - switchChannel => model.refresh, - update => model.refresh, + switchChannel => model.storeSnap != null ? model.refresh : null, + update => model.storeSnap != null ? model.refresh : null, }; } diff --git a/lib/src/snapd/snap_model.dart b/lib/src/snapd/snap_model.dart index 4afcae518..d9edcd81b 100644 --- a/lib/src/snapd/snap_model.dart +++ b/lib/src/snapd/snap_model.dart @@ -149,11 +149,27 @@ class SnapModel extends ChangeNotifier { await snapd.abortChange(activeChangeId!); } - Future install() => - _snapAction(() => snapd.install(snapName, channel: selectedChannel)); + Future install() { + assert(storeSnap?.channels[selectedChannel] != null, + 'install() should not be called before the store snap is available'); + return _snapAction(() => snapd.install( + snapName, + channel: selectedChannel, + classic: storeSnap!.channels[selectedChannel]!.confinement == + SnapConfinement.classic, + )); + } - Future refresh() => - _snapAction(() => snapd.refresh(snapName, channel: selectedChannel)); + Future refresh() { + assert(storeSnap?.channels[selectedChannel] != null, + 'remove() should not be called before the store snap is available'); + return _snapAction(() => snapd.refresh( + snapName, + channel: selectedChannel, + classic: storeSnap!.channels[selectedChannel]!.confinement == + SnapConfinement.classic, + )); + } Future remove() => _snapAction(() => snapd.remove(snapName)); } diff --git a/pubspec.yaml b/pubspec.yaml index 53bf63403..06e0800d3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: 1.0.0-alpha publish_to: 'none' environment: - sdk: '3.0.5' - flutter: '3.10.5' + sdk: '^3.0.6' + flutter: '^3.10.6' dependencies: args: ^2.4.2 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e538a8a95..8bc8db76e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -9,7 +9,7 @@ version: git parts: flutter-git: source: https://github.com/flutter/flutter.git - source-tag: 3.10.5 + source-tag: 3.10.6 source-depth: 1 plugin: nil override-build: | diff --git a/test/snap_model_test.dart b/test/snap_model_test.dart index 9023e64ef..91f4a4d99 100644 --- a/test/snap_model_test.dart +++ b/test/snap_model_test.dart @@ -99,7 +99,11 @@ void main() { await model.install(); - verify(service.install('testsnap', channel: 'latest/stable')).called(1); + verify(service.install( + 'testsnap', + channel: 'latest/stable', + classic: false, + )).called(1); }); test('non-default channel', () async { final service = createMockSnapdService( @@ -111,7 +115,11 @@ void main() { model.selectedChannel = 'latest/edge'; await model.install(); - verify(service.install('testsnap', channel: 'latest/edge')).called(1); + verify(service.install( + 'testsnap', + channel: 'latest/edge', + classic: true, + )).called(1); }); }); @@ -126,7 +134,11 @@ void main() { await model.refresh(); - verify(service.refresh('testsnap', channel: 'latest/edge')).called(1); + verify(service.refresh( + 'testsnap', + channel: 'latest/edge', + classic: true, + )).called(1); }); test('switch channel', () async { final service = createMockSnapdService( @@ -139,7 +151,11 @@ void main() { model.selectedChannel = 'latest/stable'; await model.refresh(); - verify(service.refresh('testsnap', channel: 'latest/stable')).called(1); + verify(service.refresh( + 'testsnap', + channel: 'latest/stable', + classic: false, + )).called(1); }); }); @@ -164,8 +180,11 @@ void main() { final changeCompleter = Completer(); final notifyCompleter = Completer(); - when(service.install(any, channel: anyNamed('channel'))) - .thenAnswer((_) async => 'changeId'); + when(service.install( + any, + channel: anyNamed('channel'), + classic: anyNamed('classic'), + )).thenAnswer((_) async => 'changeId'); when(service.waitChange('changeId')) .thenAnswer((_) async => await changeCompleter.future); when(service.abortChange('changeId')).thenAnswer((_) async { diff --git a/test/test_utils.dart b/test/test_utils.dart index 541b4958a..a328dc96e 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -104,10 +104,16 @@ MockSnapdService createMockSnapdService({ kind: 'snap-not-found', )); } - when(service.install(any, channel: anyNamed('channel'))) - .thenAnswer((_) async => 'id'); - when(service.refresh(any, channel: anyNamed('channel'))) - .thenAnswer((_) async => 'id'); + when(service.install( + any, + channel: anyNamed('channel'), + classic: anyNamed('classic'), + )).thenAnswer((_) async => 'id'); + when(service.refresh( + any, + channel: anyNamed('channel'), + classic: anyNamed('classic'), + )).thenAnswer((_) async => 'id'); when(service.remove(any)).thenAnswer((_) async => 'id'); when(service.find(filter: SnapFindFilter.refresh)) .thenAnswer((_) async => refreshableSnaps ?? []);