diff --git a/flutter/lib/desktop/pages/connection_page.dart b/flutter/lib/desktop/pages/connection_page.dart index d366d06ec..5fd6b4a28 100644 --- a/flutter/lib/desktop/pages/connection_page.dart +++ b/flutter/lib/desktop/pages/connection_page.dart @@ -33,7 +33,7 @@ class _ConnectionPageState extends State { final _idController = TextEditingController(); /// Update url. If it's not null, means an update is available. - var _updateUrl = ''; + final _updateUrl = ''; Timer? _updateTimer; @@ -92,7 +92,7 @@ class _ConnectionPageState extends State { if (snapshot.hasData) { return snapshot.data!; } else { - return Offstage(); + return const Offstage(); } }), ], @@ -110,7 +110,7 @@ class _ConnectionPageState extends State { /// Callback for the connect button. /// Connects to the selected peer. void onConnect({bool isFileTransfer = false}) { - var id = _idController.text.trim(); + final id = _idController.text.trim(); connect(id, isFileTransfer: isFileTransfer); } @@ -120,9 +120,9 @@ class _ConnectionPageState extends State { if (id == '') return; id = id.replaceAll(' ', ''); if (isFileTransfer) { - await rustDeskWinManager.new_file_transfer(id); + await rustDeskWinManager.newFileTransfer(id); } else { - await rustDeskWinManager.new_remote_desktop(id); + await rustDeskWinManager.newRemoteDesktop(id); } FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { diff --git a/flutter/lib/desktop/widgets/peer_widget.dart b/flutter/lib/desktop/widgets/peer_widget.dart index 3bfff60bf..02b5b9f00 100644 --- a/flutter/lib/desktop/widgets/peer_widget.dart +++ b/flutter/lib/desktop/widgets/peer_widget.dart @@ -21,18 +21,16 @@ final peerSearchTextController = TextEditingController(text: peerSearchText.value); class _PeerWidget extends StatefulWidget { - late final _peers; - late final OffstageFunc _offstageFunc; - late final PeerCardWidgetFunc _peerCardWidgetFunc; + final Peers peers; + final OffstageFunc offstageFunc; + final PeerCardWidgetFunc peerCardWidgetFunc; - _PeerWidget(Peers peers, OffstageFunc offstageFunc, - PeerCardWidgetFunc peerCardWidgetFunc, - {Key? key}) - : super(key: key) { - _peers = peers; - _offstageFunc = offstageFunc; - _peerCardWidgetFunc = peerCardWidgetFunc; - } + const _PeerWidget( + {required this.peers, + required this.offstageFunc, + required this.peerCardWidgetFunc, + Key? key}) + : super(key: key); @override _PeerWidgetState createState() => _PeerWidgetState(); @@ -42,9 +40,9 @@ class _PeerWidget extends StatefulWidget { class _PeerWidgetState extends State<_PeerWidget> with WindowListener { static const int _maxQueryCount = 3; - var _curPeers = Set(); + final _curPeers = {}; var _lastChangeTime = DateTime.now(); - var _lastQueryPeers = Set(); + var _lastQueryPeers = {}; var _lastQueryTime = DateTime.now().subtract(Duration(hours: 1)); var _queryCoun = 0; var _exit = false; @@ -78,65 +76,62 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener { @override Widget build(BuildContext context) { - final space = 12.0; + const space = 12.0; return ChangeNotifierProvider( - create: (context) => super.widget._peers, + create: (context) => widget.peers, child: Consumer( - builder: (context, peers, child) => peers.peers.isEmpty - ? Center( - child: Text(translate("Empty")), - ) - : SingleChildScrollView( - child: ObxValue((searchText) { - return FutureBuilder>( - builder: (context, snapshot) { - if (snapshot.hasData) { - final peers = snapshot.data!; - final cards = []; - for (final peer in peers) { - cards.add(Offstage( - key: ValueKey("off${peer.id}"), - offstage: super.widget._offstageFunc(peer), - child: Obx( - () => SizedBox( - width: 220, - height: - peerCardUiType.value == PeerUiType.grid - ? 140 - : 42, - child: VisibilityDetector( - key: ValueKey(peer.id), - onVisibilityChanged: (info) { - final peerId = - (info.key as ValueKey).value; - if (info.visibleFraction > 0.00001) { - _curPeers.add(peerId); - } else { - _curPeers.remove(peerId); - } - _lastChangeTime = DateTime.now(); - }, - child: super - .widget - ._peerCardWidgetFunc(peer), - ), + builder: (context, peers, child) => peers.peers.isEmpty + ? Center( + child: Text(translate("Empty")), + ) + : SingleChildScrollView( + child: ObxValue((searchText) { + return FutureBuilder>( + builder: (context, snapshot) { + if (snapshot.hasData) { + final peers = snapshot.data!; + final cards = []; + for (final peer in peers) { + cards.add(Offstage( + key: ValueKey("off${peer.id}"), + offstage: widget.offstageFunc(peer), + child: Obx( + () => SizedBox( + width: 220, + height: + peerCardUiType.value == PeerUiType.grid + ? 140 + : 42, + child: VisibilityDetector( + key: ValueKey(peer.id), + onVisibilityChanged: (info) { + final peerId = + (info.key as ValueKey).value; + if (info.visibleFraction > 0.00001) { + _curPeers.add(peerId); + } else { + _curPeers.remove(peerId); + } + _lastChangeTime = DateTime.now(); + }, + child: widget.peerCardWidgetFunc(peer), ), - ))); - } - return Wrap( - spacing: space, - runSpacing: space, - children: cards); - } else { - return const Center( - child: CircularProgressIndicator(), - ); + ), + ))); } - }, - future: matchPeers(searchText.value, peers.peers), - ); - }, peerSearchText), - )), + return Wrap( + spacing: space, runSpacing: space, children: cards); + } else { + return const Center( + child: CircularProgressIndicator(), + ); + } + }, + future: matchPeers(searchText.value, peers.peers), + ); + }, peerSearchText), + ), + ), ); } @@ -175,31 +170,42 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener { } abstract class BasePeerWidget extends StatelessWidget { - late final _name; - late final _loadEvent; - late final OffstageFunc _offstageFunc; - late final PeerCardWidgetFunc _peerCardWidgetFunc; - late final List _initPeers; + final String name; + final String loadEvent; + final OffstageFunc offstageFunc; + final PeerCardWidgetFunc peerCardWidgetFunc; + final List initPeers; - BasePeerWidget({Key? key}) : super(key: key) {} + const BasePeerWidget({ + Key? key, + required this.name, + required this.loadEvent, + required this.offstageFunc, + required this.peerCardWidgetFunc, + required this.initPeers, + }) : super(key: key); @override Widget build(BuildContext context) { - return _PeerWidget(Peers(_name, _loadEvent, _initPeers), _offstageFunc, - _peerCardWidgetFunc); + return _PeerWidget( + peers: Peers(name: name, loadEvent: loadEvent, peers: initPeers), + offstageFunc: offstageFunc, + peerCardWidgetFunc: peerCardWidgetFunc); } } class RecentPeerWidget extends BasePeerWidget { - RecentPeerWidget({Key? key}) : super(key: key) { - super._name = "recent peer"; - super._loadEvent = "load_recent_peers"; - super._offstageFunc = (Peer _peer) => false; - super._peerCardWidgetFunc = (Peer peer) => RecentPeerCard( - peer: peer, + RecentPeerWidget({Key? key}) + : super( + key: key, + name: 'recent peer', + loadEvent: 'load_recent_peers', + offstageFunc: (Peer peer) => false, + peerCardWidgetFunc: (Peer peer) => RecentPeerCard( + peer: peer, + ), + initPeers: [], ); - super._initPeers = []; - } @override Widget build(BuildContext context) { @@ -210,13 +216,17 @@ class RecentPeerWidget extends BasePeerWidget { } class FavoritePeerWidget extends BasePeerWidget { - FavoritePeerWidget({Key? key}) : super(key: key) { - super._name = "favorite peer"; - super._loadEvent = "load_fav_peers"; - super._offstageFunc = (Peer _peer) => false; - super._peerCardWidgetFunc = (Peer peer) => FavoritePeerCard(peer: peer); - super._initPeers = []; - } + FavoritePeerWidget({Key? key}) + : super( + key: key, + name: 'favorite peer', + loadEvent: 'load_fav_peers', + offstageFunc: (Peer peer) => false, + peerCardWidgetFunc: (Peer peer) => FavoritePeerCard( + peer: peer, + ), + initPeers: [], + ); @override Widget build(BuildContext context) { @@ -227,13 +237,17 @@ class FavoritePeerWidget extends BasePeerWidget { } class DiscoveredPeerWidget extends BasePeerWidget { - DiscoveredPeerWidget({Key? key}) : super(key: key) { - super._name = "discovered peer"; - super._loadEvent = "load_lan_peers"; - super._offstageFunc = (Peer _peer) => false; - super._peerCardWidgetFunc = (Peer peer) => DiscoveredPeerCard(peer: peer); - super._initPeers = []; - } + DiscoveredPeerWidget({Key? key}) + : super( + key: key, + name: 'discovered peer', + loadEvent: 'load_lan_peers', + offstageFunc: (Peer peer) => false, + peerCardWidgetFunc: (Peer peer) => DiscoveredPeerCard( + peer: peer, + ), + initPeers: [], + ); @override Widget build(BuildContext context) { @@ -244,21 +258,26 @@ class DiscoveredPeerWidget extends BasePeerWidget { } class AddressBookPeerWidget extends BasePeerWidget { - AddressBookPeerWidget({Key? key}) : super(key: key) { - super._name = "address book peer"; - super._offstageFunc = - (Peer peer) => !_hitTag(gFFI.abModel.selectedTags, peer.tags); - super._peerCardWidgetFunc = (Peer peer) => AddressBookPeerCard(peer: peer); - super._initPeers = _loadPeers(); - } + AddressBookPeerWidget({Key? key}) + : super( + key: key, + name: 'address book peer', + loadEvent: 'load_address_book_peers', + offstageFunc: (Peer peer) => + !_hitTag(gFFI.abModel.selectedTags, peer.tags), + peerCardWidgetFunc: (Peer peer) => DiscoveredPeerCard( + peer: peer, + ), + initPeers: _loadPeers(), + ); - List _loadPeers() { + static List _loadPeers() { return gFFI.abModel.peers.map((e) { return Peer.fromJson(e['id'], e); }).toList(); } - bool _hitTag(List selectedTags, List idents) { + static bool _hitTag(List selectedTags, List idents) { if (selectedTags.isEmpty) { return true; } diff --git a/flutter/lib/desktop/widgets/peercard_widget.dart b/flutter/lib/desktop/widgets/peercard_widget.dart index 3b4a30ee0..114f4146e 100644 --- a/flutter/lib/desktop/widgets/peercard_widget.dart +++ b/flutter/lib/desktop/widgets/peercard_widget.dart @@ -348,11 +348,11 @@ abstract class BasePeerCard extends StatelessWidget { assert(!(isFileTransfer && isTcpTunneling && isRDP), "more than one connect type"); if (isFileTransfer) { - await rustDeskWinManager.new_file_transfer(id); + await rustDeskWinManager.newFileTransfer(id); } else if (isTcpTunneling || isRDP) { - await rustDeskWinManager.new_port_forward(id, isRDP); + await rustDeskWinManager.newPortForward(id, isRDP); } else { - await rustDeskWinManager.new_remote_desktop(id); + await rustDeskWinManager.newRemoteDesktop(id); } FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { @@ -468,7 +468,8 @@ abstract class BasePeerCard extends StatelessWidget { } @protected - MenuEntryBase _removeAction(String id) { + MenuEntryBase _removeAction( + String id, Future Function() reloadFunc) { return MenuEntryButton( childBuilder: (TextStyle? style) => Text( translate('Remove'), @@ -478,7 +479,8 @@ abstract class BasePeerCard extends StatelessWidget { () async { await bind.mainRemovePeer(id: id); removePreference(id); - Get.forceAppUpdate(); // TODO use inner model / state + await reloadFunc(); + // Get.forceAppUpdate(); // TODO use inner model / state }(); }, dismissOnClicked: true, @@ -614,7 +616,9 @@ class RecentPeerCard extends BasePeerCard { } menuItems.add(await _forceAlwaysRelayAction(peer.id)); menuItems.add(_renameAction(peer.id, false)); - menuItems.add(_removeAction(peer.id)); + menuItems.add(_removeAction(peer.id, () async { + await bind.mainLoadRecentPeers(); + })); menuItems.add(_unrememberPasswordAction(peer.id)); menuItems.add(_addFavAction(peer.id)); return menuItems; @@ -638,7 +642,9 @@ class FavoritePeerCard extends BasePeerCard { } menuItems.add(await _forceAlwaysRelayAction(peer.id)); menuItems.add(_renameAction(peer.id, false)); - menuItems.add(_removeAction(peer.id)); + menuItems.add(_removeAction(peer.id, () async { + await bind.mainLoadFavPeers(); + })); menuItems.add(_unrememberPasswordAction(peer.id)); menuItems.add(_rmFavAction(peer.id)); return menuItems; @@ -662,9 +668,10 @@ class DiscoveredPeerCard extends BasePeerCard { } menuItems.add(await _forceAlwaysRelayAction(peer.id)); menuItems.add(_renameAction(peer.id, false)); - menuItems.add(_removeAction(peer.id)); + menuItems.add(_removeAction(peer.id, () async { + await bind.mainLoadLanPeers(); + })); menuItems.add(_unrememberPasswordAction(peer.id)); - menuItems.add(_addFavAction(peer.id)); return menuItems; } } @@ -686,7 +693,7 @@ class AddressBookPeerCard extends BasePeerCard { } menuItems.add(await _forceAlwaysRelayAction(peer.id)); menuItems.add(_renameAction(peer.id, false)); - menuItems.add(_removeAction(peer.id)); + menuItems.add(_removeAction(peer.id, () async {})); menuItems.add(_unrememberPasswordAction(peer.id)); menuItems.add(_addFavAction(peer.id)); menuItems.add(_editTagAction(peer.id)); @@ -695,7 +702,8 @@ class AddressBookPeerCard extends BasePeerCard { @protected @override - MenuEntryBase _removeAction(String id) { + MenuEntryBase _removeAction( + String id, Future Function() reloadFunc) { return MenuEntryButton( childBuilder: (TextStyle? style) => Text( translate('Remove'), diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 962998bbd..887bf7d35 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -301,6 +301,9 @@ class FfiModel with ChangeNotifier { /// Handle the peer info event based on [evt]. void handlePeerInfo(Map evt, String peerId) async { + // recent peer updated by handle_peer_info(ui_session_interface.rs) --> handle_peer_info(client.rs) --> save_config(client.rs) + bind.mainLoadRecentPeers(); + parent.target?.dialogManager.dismissAll(); _pi.version = evt['version']; _pi.username = evt['username']; @@ -556,18 +559,18 @@ class CanvasModel with ChangeNotifier { var dxOffset = 0; var dyOffset = 0; if (dw > size.width) { - final xxxx = x - dw * (x / size.width) - _x; - if (xxxx.isInfinite || xxxx.isNaN) { + final X_debugNanOrInfinite = x - dw * (x / size.width) - _x; + if (X_debugNanOrInfinite.isInfinite || X_debugNanOrInfinite.isNaN) { debugPrint( - 'REMOVE ME ============================ xxxx $x,$dw,$_scale,${size.width},$_x'); + 'REMOVE ME ============================ X_debugNanOrInfinite $x,$dw,$_scale,${size.width},$_x'); } dxOffset = (x - dw * (x / size.width) - _x).toInt(); } if (dh > size.height) { - final yyyy = y - dh * (y / size.height) - _y; - if (yyyy.isInfinite || yyyy.isNaN) { + final Y_debugNanOrInfinite = y - dh * (y / size.height) - _y; + if (Y_debugNanOrInfinite.isInfinite || Y_debugNanOrInfinite.isNaN) { debugPrint( - 'REMOVE ME ============================ xxxx $y,$dh,$_scale,${size.height},$_y'); + 'REMOVE ME ============================ Y_debugNanOrInfinite $y,$dh,$_scale,${size.height},$_y'); } dyOffset = (y - dh * (y / size.height) - _y).toInt(); } @@ -1249,20 +1252,20 @@ class PeerInfo { Future savePreference(String id, double xCursor, double yCursor, double xCanvas, double yCanvas, double scale, int currentDisplay) async { SharedPreferences prefs = await SharedPreferences.getInstance(); - final p = Map(); + final p = {}; p['xCursor'] = xCursor; p['yCursor'] = yCursor; p['xCanvas'] = xCanvas; p['yCanvas'] = yCanvas; p['scale'] = scale; p['currentDisplay'] = currentDisplay; - prefs.setString('peer' + id, json.encode(p)); + prefs.setString('peer$id', json.encode(p)); } Future?> getPreference(String id) async { if (!isWebDesktop) return null; SharedPreferences prefs = await SharedPreferences.getInstance(); - var p = prefs.getString('peer' + id); + var p = prefs.getString('peer$id'); if (p == null) return null; Map m = json.decode(p); return m; @@ -1270,7 +1273,7 @@ Future?> getPreference(String id) async { void removePreference(String id) async { SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.remove('peer' + id); + prefs.remove('peer$id'); } void initializeCursorAndCanvas(FFI ffi) async { diff --git a/flutter/lib/models/peer_model.dart b/flutter/lib/models/peer_model.dart index 5c889e60f..79b71e6db 100644 --- a/flutter/lib/models/peer_model.dart +++ b/flutter/lib/models/peer_model.dart @@ -10,9 +10,8 @@ class Peer { final List tags; bool online = false; - Peer.fromJson(String id, Map json) - : id = id, - username = json['username'] ?? '', + Peer.fromJson(this.id, Map json) + : username = json['username'] ?? '', hostname = json['hostname'] ?? '', platform = json['platform'] ?? '', tags = json['tags'] ?? []; @@ -35,57 +34,52 @@ class Peer { } class Peers extends ChangeNotifier { - late String _name; - late List _peers; - late final _loadEvent; + final String name; + final String loadEvent; + List peers; static const _cbQueryOnlines = 'callback_query_onlines'; - Peers(String name, String loadEvent, List _initPeers) { - _name = name; - _loadEvent = loadEvent; - _peers = _initPeers; - platformFFI.registerEventHandler(_cbQueryOnlines, _name, (evt) { + Peers({required this.name, required this.peers, required this.loadEvent}) { + platformFFI.registerEventHandler(_cbQueryOnlines, name, (evt) { _updateOnlineState(evt); }); - platformFFI.registerEventHandler(_loadEvent, _name, (evt) { + platformFFI.registerEventHandler(loadEvent, name, (evt) { _updatePeers(evt); }); } - List get peers => _peers; - @override void dispose() { - platformFFI.unregisterEventHandler(_cbQueryOnlines, _name); - platformFFI.unregisterEventHandler(_loadEvent, _name); + platformFFI.unregisterEventHandler(_cbQueryOnlines, name); + platformFFI.unregisterEventHandler(loadEvent, name); super.dispose(); } Peer getByIndex(int index) { - if (index < _peers.length) { - return _peers[index]; + if (index < peers.length) { + return peers[index]; } else { return Peer.loading(); } } int getPeersCount() { - return _peers.length; + return peers.length; } void _updateOnlineState(Map evt) { evt['onlines'].split(',').forEach((online) { - for (var i = 0; i < _peers.length; i++) { - if (_peers[i].id == online) { - _peers[i].online = true; + for (var i = 0; i < peers.length; i++) { + if (peers[i].id == online) { + peers[i].online = true; } } }); evt['offlines'].split(',').forEach((offline) { - for (var i = 0; i < _peers.length; i++) { - if (_peers[i].id == offline) { - _peers[i].online = false; + for (var i = 0; i < peers.length; i++) { + if (peers[i].id == offline) { + peers[i].online = false; } } }); @@ -95,19 +89,19 @@ class Peers extends ChangeNotifier { void _updatePeers(Map evt) { final onlineStates = _getOnlineStates(); - _peers = _decodePeers(evt['peers']); - _peers.forEach((peer) { + peers = _decodePeers(evt['peers']); + for (var peer in peers) { final state = onlineStates[peer.id]; peer.online = state != null && state != false; - }); + } notifyListeners(); } Map _getOnlineStates() { - var onlineStates = new Map(); - _peers.forEach((peer) { + var onlineStates = {}; + for (var peer in peers) { onlineStates[peer.id] = peer.online; - }); + } return onlineStates; } @@ -121,7 +115,7 @@ class Peers extends ChangeNotifier { Peer.fromJson(s[0] as String, s[1] as Map)) .toList(); } catch (e) { - print('peers(): $e'); + debugPrint('peers(): $e'); } return []; } diff --git a/flutter/lib/utils/multi_window_manager.dart b/flutter/lib/utils/multi_window_manager.dart index b01b84a9d..97d5a5e23 100644 --- a/flutter/lib/utils/multi_window_manager.dart +++ b/flutter/lib/utils/multi_window_manager.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:ui'; import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:flutter/material.dart'; @@ -37,9 +36,9 @@ class RustDeskMultiWindowManager { int? _fileTransferWindowId; int? _portForwardWindowId; - Future new_remote_desktop(String remote_id) async { + Future newRemoteDesktop(String remoteId) async { final msg = - jsonEncode({"type": WindowType.RemoteDesktop.index, "id": remote_id}); + jsonEncode({"type": WindowType.RemoteDesktop.index, "id": remoteId}); try { final ids = await DesktopMultiWindow.getAllSubWindowIds(); @@ -63,9 +62,9 @@ class RustDeskMultiWindowManager { } } - Future new_file_transfer(String remote_id) async { + Future newFileTransfer(String remoteId) async { final msg = - jsonEncode({"type": WindowType.FileTransfer.index, "id": remote_id}); + jsonEncode({"type": WindowType.FileTransfer.index, "id": remoteId}); try { final ids = await DesktopMultiWindow.getAllSubWindowIds(); @@ -88,12 +87,9 @@ class RustDeskMultiWindowManager { } } - Future new_port_forward(String remote_id, bool isRDP) async { - final msg = jsonEncode({ - "type": WindowType.PortForward.index, - "id": remote_id, - "isRDP": isRDP - }); + Future newPortForward(String remoteId, bool isRDP) async { + final msg = jsonEncode( + {"type": WindowType.PortForward.index, "id": remoteId, "isRDP": isRDP}); try { final ids = await DesktopMultiWindow.getAllSubWindowIds(); diff --git a/src/client.rs b/src/client.rs index 25061bcfe..32c0003fd 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1278,11 +1278,11 @@ impl LoginConfigHandler { /// /// * `username` - The name of the peer. /// * `pi` - The peer info. - pub fn handle_peer_info(&mut self, pi: PeerInfo) { + pub fn handle_peer_info(&mut self, pi: &PeerInfo) { if !pi.version.is_empty() { self.version = hbb_common::get_version_number(&pi.version); } - self.features = pi.features.into_option(); + self.features = pi.features.clone().into_option(); let serde = PeerInfoSerde { username: pi.username.clone(), hostname: pi.hostname.clone(), diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 716afacb9..6a3d19880 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -205,8 +205,8 @@ pub fn session_get_custom_image_quality(id: String) -> Option> { } pub fn session_set_custom_image_quality(id: String, value: i32) { - if let Some(session) = SESSIONS.read().unwrap().get(&id) { - session.set_custom_image_quality(value); + if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) { + session.save_custom_image_quality(value); } } diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index d89ce2d3b..5ab6089a0 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -47,6 +47,11 @@ impl Session { self.lc.read().unwrap().image_quality.clone() } + /// Get custom image quality. + pub fn get_custom_image_quality(&self) -> Vec { + self.lc.read().unwrap().custom_image_quality.clone() + } + pub fn save_view_style(&mut self, value: String) { self.lc.write().unwrap().save_view_style(value); } @@ -634,7 +639,7 @@ impl Interface for Session { } } else if !self.is_port_forward() { if pi.displays.is_empty() { - self.lc.write().unwrap().handle_peer_info(pi); + self.lc.write().unwrap().handle_peer_info(&pi); self.update_privacy_mode(); self.msgbox("error", "Remote Error", "No Display"); return; @@ -647,9 +652,9 @@ impl Interface for Session { self.set_display(current.x, current.y, current.width, current.height); } self.update_privacy_mode(); + // Save recent peers, then push event to flutter. So flutter can refresh peer page. + self.lc.write().unwrap().handle_peer_info(&pi); self.set_peer_info(&pi); - self.lc.write().unwrap().handle_peer_info(pi); - if self.is_file_transfer() { self.close_success(); } else if !self.is_port_forward() {