mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-13 03:28:03 +00:00
optimize closeConfirmDialog by using async onWindowCloseButton
This commit is contained in:
@@ -75,9 +75,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
backgroundColor: MyTheme.color(context).bg,
|
||||
body: DesktopTab(
|
||||
controller: tabController,
|
||||
onWindowCloseButton: () {
|
||||
tabController.clear();
|
||||
},
|
||||
onWindowCloseButton: handleWindowCloseButton,
|
||||
tail: const AddButton().paddingOnly(left: 10),
|
||||
)),
|
||||
),
|
||||
@@ -103,4 +101,21 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
tabController.closeBy(peerId);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> handleWindowCloseButton() async {
|
||||
final connLength = tabController.state.value.tabs.length;
|
||||
if (connLength < 1) {
|
||||
return true;
|
||||
} else if (connLength == 1) {
|
||||
final currentConn = tabController.state.value.tabs[0];
|
||||
handleTabCloseButton(currentConn.key);
|
||||
return false;
|
||||
} else {
|
||||
final res = await closeConfirmDialog();
|
||||
if (res) {
|
||||
tabController.clear();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user