Skip to content

Commit

Permalink
call show() and restore() together as an extension function
Browse files Browse the repository at this point in the history
  • Loading branch information
levkropp committed Sep 17, 2024
1 parent fa2b290 commit 418162b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/gui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 129,7 @@ class _AppState extends ConsumerState<App> with WindowListener {
final primary = ref.read(clientSettingProvider(primaryNameKey));
if (vms.contains(primary)) {
ref.read(sidebarKeyProvider.notifier).set('vm-$primary');
windowManager.show();
windowManager.showAndRestore();
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/client/gui/lib/tray_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,13 @@ import 'vm_action.dart';
import 'vm_details/terminal_tabs.dart';
import 'vm_details/vm_details.dart';

extension WindowManagerExtensions on WindowManager {
Future<void> showAndRestore() async {
await show();
await restore();
}
}

final trayMenuDataProvider = Provider.autoDispose((ref) {
return ref.watch(daemonAvailableProvider)
? ref.watch(vmStatusesProvider)
Expand Down Expand Up @@ -57,7 64,7 @@ Future<void> setupTrayMenu(ProviderContainer providerContainer) async {
label: 'Toggle window',
callback: (_, __) async => await windowManager.isVisible()
? windowManager.hide()
: windowManager.show(),
: windowManager.showAndRestore(),
);
}

Expand Down Expand Up @@ -207,7 214,7 @@ Future<void> _updateTrayMenu(
if (providerContainer.exists(provider)) {
providerContainer.read(provider.notifier).start();
}
windowManager.show();
windowManager.showAndRestore();
},
);
} else {
Expand Down

0 comments on commit 418162b

Please sign in to comment.