Merge branch 'master' of github.com-rustdesk:rustdesk/rustdesk

This commit is contained in:
rustdesk 2023-03-09 17:23:32 +08:00
commit 6734dd01c9
2 changed files with 27 additions and 21 deletions

View File

@ -45,7 +45,7 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
var _lastChangeTime = DateTime.now(); var _lastChangeTime = DateTime.now();
var _lastQueryPeers = <String>{}; var _lastQueryPeers = <String>{};
var _lastQueryTime = DateTime.now().subtract(const Duration(hours: 1)); var _lastQueryTime = DateTime.now().subtract(const Duration(hours: 1));
var _queryCoun = 0; var _queryCount = 0;
var _exit = false; var _exit = false;
late final mobileWidth = () { late final mobileWidth = () {
@ -78,12 +78,12 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
@override @override
void onWindowFocus() { void onWindowFocus() {
_queryCoun = 0; _queryCount = 0;
} }
@override @override
void onWindowMinimize() { void onWindowMinimize() {
_queryCoun = _maxQueryCount; _queryCount = _maxQueryCount;
} }
@override @override
@ -100,6 +100,19 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
); );
} }
onVisibilityChanged(VisibilityInfo info) {
final peerId = _peerId((info.key as ValueKey).value);
if (info.visibleFraction > 0.00001) {
_curPeers.add(peerId);
} else {
_curPeers.remove(peerId);
}
_lastChangeTime = DateTime.now();
}
String _cardId(String id) => widget.peers.name + id;
String _peerId(String cardId) => cardId.replaceAll(widget.peers.name, '');
Widget _buildPeersView(Peers peers) { Widget _buildPeersView(Peers peers) {
final body = ObxValue<RxString>((searchText) { final body = ObxValue<RxString>((searchText) {
return FutureBuilder<List<Peer>>( return FutureBuilder<List<Peer>>(
@ -109,16 +122,8 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
final cards = <Widget>[]; final cards = <Widget>[];
for (final peer in peers) { for (final peer in peers) {
final visibilityChild = VisibilityDetector( final visibilityChild = VisibilityDetector(
key: ValueKey(peer.id), key: ValueKey(_cardId(peer.id)),
onVisibilityChanged: (info) { onVisibilityChanged: onVisibilityChanged,
final peerId = (info.key as ValueKey).value;
if (info.visibleFraction > 0.00001) {
_curPeers.add(peerId);
} else {
_curPeers.remove(peerId);
}
_lastChangeTime = DateTime.now();
},
child: widget.peerCardBuilder(peer), child: widget.peerCardBuilder(peer),
); );
cards.add(isDesktop cards.add(isDesktop
@ -149,6 +154,7 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
// ignore: todo // ignore: todo
// TODO: variables walk through async tasks? // TODO: variables walk through async tasks?
void _startCheckOnlines() { void _startCheckOnlines() {
final queryInterval = const Duration(seconds: 20);
() async { () async {
while (!_exit) { while (!_exit) {
final now = DateTime.now(); final now = DateTime.now();
@ -158,18 +164,18 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
platformFFI.ffiBind platformFFI.ffiBind
.queryOnlines(ids: _curPeers.toList(growable: false)); .queryOnlines(ids: _curPeers.toList(growable: false));
_lastQueryPeers = {..._curPeers}; _lastQueryPeers = {..._curPeers};
_lastQueryTime = DateTime.now(); _lastQueryTime = DateTime.now().subtract(queryInterval);
_queryCoun = 0; _queryCount = 0;
} }
} }
} else { } else {
if (_queryCoun < _maxQueryCount) { if (_queryCount < _maxQueryCount) {
if (now.difference(_lastQueryTime) > const Duration(seconds: 20)) { if (now.difference(_lastQueryTime) >= queryInterval) {
if (_curPeers.isNotEmpty) { if (_curPeers.isNotEmpty) {
platformFFI.ffiBind platformFFI.ffiBind
.queryOnlines(ids: _curPeers.toList(growable: false)); .queryOnlines(ids: _curPeers.toList(growable: false));
_lastQueryTime = DateTime.now(); _lastQueryTime = DateTime.now();
_queryCoun += 1; _queryCount += 1;
} }
} }
} }

View File

@ -461,8 +461,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Resolution", "Разрешение"), ("Resolution", "Разрешение"),
("No transfers in progress", "Передача не осуществляется"), ("No transfers in progress", "Передача не осуществляется"),
("Set one-time password length", "Установить длину одноразового пароля"), ("Set one-time password length", "Установить длину одноразового пароля"),
("idd_driver_tip", ""), ("idd_driver_tip", "Установите драйвер виртуального дисплея, который используется при отсутствии физических дисплеев."),
("confirm_idd_driver_tip", ""), ("confirm_idd_driver_tip", "Включена функция установки драйвера виртуального дисплея. Обратите внимание, что для доверия к драйверу будет установлен тестовый сертификат. Этот сертификат будет использоваться только для подтверждения доверия драйверам Rustdesk."),
("RDP Settings", ""), ("RDP Settings", "Настройки RDP"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }