fix, dialog button, reconnect cancel in a short time
1. Two `reconnect` is called. 2. The window cannot be closed. Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
3e61b89499
commit
69062dca16
@ -996,11 +996,20 @@ void msgBox(SessionID sessionId, String type, String title, String text,
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (reconnect != null && title == "Connection Error") {
|
if (reconnect != null && title == "Connection Error") {
|
||||||
buttons.insert(
|
final enabled = true.obs;
|
||||||
0,
|
final button = Obx(
|
||||||
dialogButton('Reconnect', isOutline: true, onPressed: () {
|
() => dialogButton(
|
||||||
reconnect(dialogManager, sessionId, false);
|
'Reconnect',
|
||||||
}));
|
isOutline: true,
|
||||||
|
onPressed: enabled.isTrue
|
||||||
|
? () {
|
||||||
|
enabled.value = false;
|
||||||
|
reconnect(dialogManager, sessionId, false);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
buttons.insert(0, button);
|
||||||
}
|
}
|
||||||
if (link.isNotEmpty) {
|
if (link.isNotEmpty) {
|
||||||
buttons.insert(0, dialogButton('JumpLink', onPressed: jumplink));
|
buttons.insert(0, dialogButton('JumpLink', onPressed: jumplink));
|
||||||
|
@ -7,7 +7,6 @@ import 'dart:io';
|
|||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/consts.dart';
|
import 'package:flutter_hbb/consts.dart';
|
||||||
import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart';
|
|
||||||
import 'package:flutter_hbb/models/state_model.dart';
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
@ -415,8 +415,24 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
|
|
||||||
void onRemoveId(String id) async {
|
void onRemoveId(String id) async {
|
||||||
if (tabController.state.value.tabs.isEmpty) {
|
if (tabController.state.value.tabs.isEmpty) {
|
||||||
await WindowController.fromWindowId(windowId()).close();
|
|
||||||
stateGlobal.setFullscreen(false, procWnd: false);
|
stateGlobal.setFullscreen(false, procWnd: false);
|
||||||
|
// Keep calling until the window status is hidden.
|
||||||
|
//
|
||||||
|
// Workaround for Windows:
|
||||||
|
// If you click other buttons and close in msgbox within a very short period of time, the close may fail.
|
||||||
|
// `await WindowController.fromWindowId(windowId()).close();`.
|
||||||
|
Future<void> loopCloseWindow() async {
|
||||||
|
int c = 0;
|
||||||
|
final windowController = WindowController.fromWindowId(windowId());
|
||||||
|
while (c < 100 &&
|
||||||
|
tabController.state.value.tabs.isEmpty &&
|
||||||
|
(!await windowController.isHidden())) {
|
||||||
|
await windowController.close();
|
||||||
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loopCloseWindow();
|
||||||
}
|
}
|
||||||
ConnectionTypeState.delete(id);
|
ConnectionTypeState.delete(id);
|
||||||
_update_remote_count();
|
_update_remote_count();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
@ -9,7 +8,6 @@ import 'package:desktop_multi_window/desktop_multi_window.dart';
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart' hide TabBarTheme;
|
import 'package:flutter/material.dart' hide TabBarTheme;
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/common/shared_state.dart';
|
|
||||||
import 'package:flutter_hbb/consts.dart';
|
import 'package:flutter_hbb/consts.dart';
|
||||||
import 'package:flutter_hbb/main.dart';
|
import 'package:flutter_hbb/main.dart';
|
||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
|
@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_hbb/common/widgets/peers_view.dart';
|
import 'package:flutter_hbb/common/widgets/peers_view.dart';
|
||||||
import 'package:flutter_hbb/models/model.dart';
|
import 'package:flutter_hbb/models/model.dart';
|
||||||
import 'package:flutter_hbb/models/peer_model.dart';
|
import 'package:flutter_hbb/models/peer_model.dart';
|
||||||
import 'package:flutter_hbb/models/peer_tab_model.dart';
|
|
||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:bot_toast/bot_toast.dart';
|
import 'package:bot_toast/bot_toast.dart';
|
||||||
|
@ -8,7 +8,6 @@ import 'package:desktop_multi_window/desktop_multi_window.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/consts.dart';
|
import 'package:flutter_hbb/consts.dart';
|
||||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
|
||||||
import 'package:flutter_hbb/generated_bridge.dart';
|
import 'package:flutter_hbb/generated_bridge.dart';
|
||||||
import 'package:flutter_hbb/models/ab_model.dart';
|
import 'package:flutter_hbb/models/ab_model.dart';
|
||||||
import 'package:flutter_hbb/models/chat_model.dart';
|
import 'package:flutter_hbb/models/chat_model.dart';
|
||||||
|
@ -1078,7 +1078,8 @@ pub fn session_next_rgba(session_id: SessionID) {
|
|||||||
pub fn session_register_texture(_session_id: SessionID, _ptr: usize) {
|
pub fn session_register_texture(_session_id: SessionID, _ptr: usize) {
|
||||||
#[cfg(feature = "flutter_texture_render")]
|
#[cfg(feature = "flutter_texture_render")]
|
||||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&_session_id) {
|
if let Some(session) = SESSIONS.write().unwrap().get_mut(&_session_id) {
|
||||||
return session.register_texture(_ptr);
|
session.register_texture(_ptr);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user