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 16, 2024
1 parent fa2b290 commit 5a93cd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 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
13 changes: 9 additions & 4 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 @@ -55,9 +62,7 @@ Future<void> setupTrayMenu(ProviderContainer providerContainer) async {
await TrayMenu.instance.addLabel(
'toggle-window',
label: 'Toggle window',
callback: (_, __) async => await windowManager.isVisible()
? windowManager.hide()
: windowManager.show(),
callback: (_, __) async => await windowManager.showAndRestore(),
);
}

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

0 comments on commit 5a93cd1

Please sign in to comment.