Skip to content

Commit 6f1b4d8

Browse files
committed
rm config setPreventClose, buggy on macos
1 parent ebcf883 commit 6f1b4d8

File tree

4 files changed

+2
-50
lines changed

4 files changed

+2
-50
lines changed

flutter_app/lib/app/controllers/fungi_controller.dart

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'package:fungi_app/src/rust/api/fungi.dart';
33
import 'package:get/get.dart';
44
import 'package:get_storage/get_storage.dart';
55
import 'package:fungi_app/src/rust/api/fungi.dart' as fungi;
6-
import 'package:window_manager/window_manager.dart';
76

87
enum ThemeOption { light, dark, system }
98

@@ -46,7 +45,6 @@ class FungiController extends GetxController {
4645

4746
final _storage = GetStorage();
4847
final _themeKey = 'theme_option';
49-
final _preventCloseKey = 'prevent_close';
5048

5149
final currentTheme = ThemeOption.system.obs;
5250
final preventClose = false.obs;
@@ -72,7 +70,6 @@ class FungiController extends GetxController {
7270
super.onInit();
7371
initFungi();
7472
loadThemeOption();
75-
loadPreventClose();
7673
}
7774

7875
void loadThemeOption() {
@@ -88,29 +85,6 @@ class FungiController extends GetxController {
8885
_storage.write(_themeKey, option.index);
8986
}
9087

91-
Future<bool> loadPreventClose() async {
92-
bool? savedPreventClose = _storage.read(_preventCloseKey);
93-
if (savedPreventClose == null) {
94-
savedPreventClose = true;
95-
_storage.write(_preventCloseKey, savedPreventClose);
96-
}
97-
windowManager.setPreventClose(savedPreventClose);
98-
final isPreventClose = await windowManager.isPreventClose();
99-
assert(
100-
isPreventClose == savedPreventClose,
101-
'Prevent close state mismatch: $isPreventClose != $savedPreventClose',
102-
);
103-
preventClose.value = isPreventClose;
104-
debugPrint('Prevent close state loaded: $isPreventClose');
105-
return isPreventClose;
106-
}
107-
108-
void changePreventClose(bool value) {
109-
_storage.write(_preventCloseKey, value);
110-
windowManager.setPreventClose(value);
111-
preventClose.value = value;
112-
}
113-
11488
void updateIncomingAllowedPeers() {
11589
incomingAllowdPeers.value = fungi.getIncomingAllowedPeersList();
11690
incomingAllowedPeersWithInfo.value = fungi

flutter_app/lib/app/tray_manager.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,9 @@ class AppTrayManager extends GetxService with TrayListener, WindowListener {
117117

118118
@override
119119
void onWindowClose() {
120-
debugPrint(
121-
'Window close event captured, hiding window... ${windowManager.isPreventClose()}',
122-
);
123120
hideWindow();
124121
}
125122

126123
@override
127-
void onWindowMinimize() {
128-
debugPrint('Window minimize event captured');
129-
}
124+
void onWindowMinimize() {}
130125
}

flutter_app/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void main() async {
2828
);
2929
windowManager.waitUntilReadyToShow(windowOptions, () async {
3030
await windowManager.show();
31+
await windowManager.setPreventClose(true);
3132
});
3233
}
3334

flutter_app/lib/ui/pages/settings/settings.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,6 @@ class Settings extends GetView<FungiController> {
3131
_showThemeDialog();
3232
},
3333
),
34-
SettingsTile.switchTile(
35-
leading: Icon(Icons.close),
36-
activeSwitchColor: Theme.of(context).colorScheme.primary,
37-
description: Text(
38-
'Minimize the app to the system tray when the close button is pressed.',
39-
style: Theme.of(context).textTheme.labelSmall?.apply(
40-
color: Theme.of(
41-
context,
42-
).colorScheme.onSurface.withAlpha(150),
43-
),
44-
),
45-
initialValue: controller.preventClose.value,
46-
onToggle: (value) {
47-
controller.changePreventClose(value);
48-
},
49-
title: Text('Minimize to Tray'),
50-
),
51-
5234
SettingsTile.navigation(
5335
leading: Icon(Icons.file_open),
5436
title: Text('Config file path'),

0 commit comments

Comments
 (0)