diff --git a/packages/app_center/lib/src/manage/manage_page.dart b/packages/app_center/lib/src/manage/manage_page.dart index 0cdf57827..1f5cbce8e 100644 --- a/packages/app_center/lib/src/manage/manage_page.dart +++ b/packages/app_center/lib/src/manage/manage_page.dart @@ -234,6 +234,9 @@ class _ActionButtons extends ConsumerWidget { error: (_, __) => ('', const SizedBox.shrink()), ); + final updatesInprogress = updatesModel.refreshableSnapNames.isNotEmpty && + !updatesModel.state.isLoading && + updatesModel.activeChangeId != null; return Row( mainAxisSize: MainAxisSize.min, children: [ @@ -306,9 +309,7 @@ class _ActionButtons extends ConsumerWidget { ), const SizedBox(width: 8), PushButton.outlined( - onPressed: updatesModel.refreshableSnapNames.isNotEmpty && - !updatesModel.state.isLoading && - updatesModel.activeChangeId != null + onPressed: updatesInprogress ? () => ref .read(updatesModelProvider) .cancelChange(updatesModel.activeChangeId!) diff --git a/packages/app_center/test/test_utils.mocks.dart b/packages/app_center/test/test_utils.mocks.dart index 41e3e0160..488cc2c30 100644 --- a/packages/app_center/test/test_utils.mocks.dart +++ b/packages/app_center/test/test_utils.mocks.dart @@ -1452,6 +1452,16 @@ class MockUpdatesModel extends _i1.Mock implements _i6.UpdatesModel { returnValueForMissingStub: _i14.Future.value(), ) as _i14.Future); + @override + _i14.Future cancelChange(String? changeId) => (super.noSuchMethod( + Invocation.method( + #cancelChange, + [changeId], + ), + returnValue: _i14.Future.value(), + returnValueForMissingStub: _i14.Future.value(), + ) as _i14.Future); + @override void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( Invocation.method(