ab: sync all recent peers if option enabled

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-08-16 08:59:50 +08:00
parent 29c661d919
commit 553a3798a1
42 changed files with 183 additions and 96 deletions

View File

@ -1,9 +1,11 @@
import 'dart:io'; import 'dart:io';
import 'package:bot_toast/bot_toast.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/common/widgets/dialog.dart'; import 'package:flutter_hbb/common/widgets/dialog.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/ab_model.dart';
import 'package:flutter_hbb/models/peer_tab_model.dart'; import 'package:flutter_hbb/models/peer_tab_model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -707,6 +709,11 @@ abstract class BasePeerCard extends StatelessWidget {
case PeerTabIndex.ab: case PeerTabIndex.ab:
gFFI.abModel.deletePeer(id); gFFI.abModel.deletePeer(id);
await gFFI.abModel.pushAb(); await gFFI.abModel.pushAb();
if (shouldSyncAb() && await bind.mainPeerExists(id: peer.id)) {
BotToast.showText(
contentColor: Colors.lightBlue,
text: translate('synced_peer_readded_tip'));
}
break; break;
case PeerTabIndex.group: case PeerTabIndex.group:
break; break;

View File

@ -1,3 +1,4 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common/widgets/address_book.dart'; import 'package:flutter_hbb/common/widgets/address_book.dart';
import 'package:flutter_hbb/common/widgets/dialog.dart'; import 'package:flutter_hbb/common/widgets/dialog.dart';
@ -7,6 +8,7 @@ import 'package:flutter_hbb/common/widgets/peer_card.dart';
import 'package:flutter_hbb/common/widgets/animated_rotation_widget.dart'; import 'package:flutter_hbb/common/widgets/animated_rotation_widget.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/widgets/popup_menu.dart'; import 'package:flutter_hbb/desktop/widgets/popup_menu.dart';
import 'package:flutter_hbb/models/ab_model.dart';
import 'package:flutter_hbb/models/peer_tab_model.dart'; import 'package:flutter_hbb/models/peer_tab_model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -122,12 +124,11 @@ class _PeerTabPageState extends State<PeerTabPage>
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(6)), borderRadius: BorderRadius.circular(6)),
child: Tooltip( child: Tooltip(
message: translate('Toggle Tags'), message: translate('Toggle Tags'),
child: Icon( child: Icon(
Icons.tag_rounded, Icons.tag_rounded,
size: 18, size: 18,
)) )))),
)),
onTap: () async { onTap: () async {
await bind.mainSetLocalOption( await bind.mainSetLocalOption(
key: "hideAbTagsPanel", key: "hideAbTagsPanel",
@ -221,13 +222,12 @@ class _PeerTabPageState extends State<PeerTabPage>
child: RotatedBox( child: RotatedBox(
quarterTurns: 2, quarterTurns: 2,
child: Tooltip( child: Tooltip(
message: translate('Refresh'), message: translate('Refresh'),
child: Icon( child: Icon(
Icons.refresh, Icons.refresh,
size: 18, size: 18,
color: textColor, color: textColor,
)) )))),
)),
), ),
); );
} }
@ -243,29 +243,28 @@ class _PeerTabPageState extends State<PeerTabPage>
return Obx( return Obx(
() => Container( () => Container(
padding: EdgeInsets.all(4.0), padding: EdgeInsets.all(4.0),
decoration: hover.value ? deco : null, decoration: hover.value ? deco : null,
child: InkWell( child: InkWell(
onHover: (value) => hover.value = value, onHover: (value) => hover.value = value,
onTap: () async { onTap: () async {
final type = types.elementAt( final type = types.elementAt(
peerCardUiType.value == types.elementAt(0) ? 1 : 0); peerCardUiType.value == types.elementAt(0) ? 1 : 0);
await bind.setLocalFlutterOption( await bind.setLocalFlutterOption(
k: 'peer-card-ui-type', v: type.index.toString()); k: 'peer-card-ui-type', v: type.index.toString());
peerCardUiType.value = type; peerCardUiType.value = type;
}, },
child: Tooltip( child: Tooltip(
message: peerCardUiType.value == PeerUiType.grid message: peerCardUiType.value == PeerUiType.grid
? translate('List View') ? translate('List View')
: translate('Grid View'), : translate('Grid View'),
child: Icon( child: Icon(
peerCardUiType.value == PeerUiType.grid peerCardUiType.value == PeerUiType.grid
? Icons.view_list_rounded ? Icons.view_list_rounded
: Icons.grid_view_rounded, : Icons.grid_view_rounded,
size: 18, size: 18,
color: textColor, color: textColor,
)) )))),
)),
); );
} }
@ -280,12 +279,12 @@ class _PeerTabPageState extends State<PeerTabPage>
model.setMultiSelectionMode(true); model.setMultiSelectionMode(true);
}, },
child: Tooltip( child: Tooltip(
message: translate('Select'), message: translate('Select'),
child: Icon( child: Icon(
IconFont.checkbox, IconFont.checkbox,
size: 18, size: 18,
color: textColor, color: textColor,
)), )),
), ),
); );
} }
@ -334,8 +333,25 @@ class _PeerTabPageState extends State<PeerTabPage>
await bind.mainLoadLanPeers(); await bind.mainLoadLanPeers();
break; break;
case 3: case 3:
gFFI.abModel.deletePeers(peers.map((p) => p.id).toList()); {
await gFFI.abModel.pushAb(); bool hasSynced = false;
if (shouldSyncAb()) {
for (var p in peers) {
if (await bind.mainPeerExists(id: p.id)) {
hasSynced = true;
}
}
}
gFFI.abModel.deletePeers(peers.map((p) => p.id).toList());
await gFFI.abModel.pushAb();
if (hasSynced) {
Future.delayed(Duration(seconds: 2), () {
BotToast.showText(
contentColor: Colors.lightBlue,
text: translate('synced_peer_readded_tip'));
});
}
}
break; break;
default: default:
break; break;
@ -483,8 +499,7 @@ class _PeerSearchBarState extends State<PeerSearchBar> {
child: Icon( child: Icon(
Icons.search_rounded, Icons.search_rounded,
color: Theme.of(context).hintColor, color: Theme.of(context).hintColor,
)) )));
);
} }
Widget _buildSearchBar() { Widget _buildSearchBar() {
@ -543,22 +558,21 @@ class _PeerSearchBarState extends State<PeerSearchBar> {
), ),
// Icon(Icons.close), // Icon(Icons.close),
IconButton( IconButton(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 2), padding: const EdgeInsets.only(right: 2),
onPressed: () { onPressed: () {
setState(() { setState(() {
peerSearchTextController.clear(); peerSearchTextController.clear();
peerSearchText.value = ""; peerSearchText.value = "";
drawer = false; drawer = false;
}); });
}, },
icon: Tooltip( icon: Tooltip(
message: translate('Close'), message: translate('Close'),
child: child: Icon(
Icon( Icons.close,
Icons.close, color: Theme.of(context).hintColor,
color: Theme.of(context).hintColor, )),
)),
), ),
], ],
), ),
@ -628,7 +642,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
child: Icon( child: Icon(
Icons.sort_rounded, Icons.sort_rounded,
size: 18, size: 18,
)), )),
onTapDown: (details) { onTapDown: (details) {
final x = details.globalPosition.dx; final x = details.globalPosition.dx;
final y = details.globalPosition.dy; final y = details.globalPosition.dy;

View File

@ -344,33 +344,28 @@ class AbModel {
} }
Future<void> _syncFromRecentWithoutLock({bool push = true}) async { Future<void> _syncFromRecentWithoutLock({bool push = true}) async {
bool shouldSync(Peer a, Peer b) { bool shouldSync(Peer r, Peer p) {
return a.hash != b.hash || return r.hash != p.hash ||
a.username != b.username || r.username != p.username ||
a.platform != b.platform || r.platform != p.platform ||
a.hostname != b.hostname || r.hostname != p.hostname ||
a.alias != b.alias; (p.alias.isEmpty && r.alias.isNotEmpty);
} }
Future<List<Peer>> getRecentPeers() async { Future<List<Peer>> getRecentPeers() async {
try { try {
if (peers.isEmpty) [];
List<String> filteredPeerIDs; List<String> filteredPeerIDs;
if (_syncAllFromRecent) { if (_syncAllFromRecent) {
_syncAllFromRecent = false; _syncAllFromRecent = false;
filteredPeerIDs = peers.map((e) => e.id).toList(); filteredPeerIDs = [];
} else { } else {
final new_stored_str = await bind.mainGetNewStoredPeers(); final new_stored_str = await bind.mainGetNewStoredPeers();
if (new_stored_str.isEmpty) return []; if (new_stored_str.isEmpty) return [];
List<String> new_stores = filteredPeerIDs = (jsonDecode(new_stored_str) as List<dynamic>)
(jsonDecode(new_stored_str) as List<dynamic>) .map((e) => e.toString())
.map((e) => e.toString()) .toList();
.toList(); if (filteredPeerIDs.isEmpty) return [];
final abPeerIds = peers.map((e) => e.id).toList();
filteredPeerIDs =
new_stores.where((e) => abPeerIds.contains(e)).toList();
} }
if (filteredPeerIDs.isEmpty) return [];
final loadStr = await bind.mainLoadRecentPeersForAb( final loadStr = await bind.mainLoadRecentPeersForAb(
filter: jsonEncode(filteredPeerIDs)); filter: jsonEncode(filteredPeerIDs));
if (loadStr.isEmpty) { if (loadStr.isEmpty) {
@ -392,28 +387,32 @@ class AbModel {
try { try {
if (!shouldSyncAb()) return; if (!shouldSyncAb()) return;
final oldPeers = peers.toList();
final recents = await getRecentPeers(); final recents = await getRecentPeers();
if (recents.isEmpty) return; if (recents.isEmpty) return;
for (var i = 0; i < peers.length; i++) { bool syncChanged = false;
var p = peers[i]; bool uiChanged = false;
var r = recents.firstWhereOrNull((r) => p.id == r.id); for (var i = 0; i < recents.length; i++) {
if (r != null) { var r = recents[i];
peers[i] = merge(r, p); var index = peers.indexWhere((e) => e.id == r.id);
} if (index < 0) {
} peers.add(r);
bool changed = false; syncChanged = true;
for (var i = 0; i < peers.length; i++) { uiChanged = true;
final o = oldPeers[i]; } else {
final p = peers[i]; if (!r.equal(peers[index])) {
if (shouldSync(o, p)) { uiChanged = true;
changed = true; }
break; if (shouldSync(r, peers[index])) {
syncChanged = true;
}
peers[index] = merge(r, peers[index]);
} }
} }
// Be careful with loop calls // Be careful with loop calls
if (changed && push) { if (syncChanged && push) {
pushAb(); pushAb();
} else if (uiChanged) {
peers.refresh();
} }
} catch (e) { } catch (e) {
debugPrint('syncFromRecent:$e'); debugPrint('syncFromRecent:$e');

View File

@ -1,6 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'platform_model.dart'; import 'platform_model.dart';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
class Peer { class Peer {
final String id; final String id;
@ -87,6 +89,18 @@ class Peer {
rdpPort: '', rdpPort: '',
rdpUsername: '', rdpUsername: '',
); );
bool equal(Peer other) {
return id == other.id &&
hash == other.hash &&
username == other.username &&
hostname == other.hostname &&
platform == other.platform &&
alias == other.alias &&
tags.equals(other.tags) &&
forceAlwaysRelay == other.forceAlwaysRelay &&
rdpPort == other.rdpPort &&
rdpUsername == other.rdpUsername;
}
} }
enum UpdateEvent { online, load } enum UpdateEvent { online, load }

View File

@ -1079,6 +1079,10 @@ impl PeerConfig {
Default::default() Default::default()
} }
pub fn exists(id: &str) -> bool {
Self::path(id).exists()
}
serde_field_string!( serde_field_string!(
default_view_style, default_view_style,
deserialize_view_style, deserialize_view_style,

View File

@ -841,6 +841,10 @@ pub fn main_peer_has_password(id: String) -> bool {
peer_has_password(id) peer_has_password(id)
} }
pub fn main_peer_exists(id: String) -> bool {
peer_exists(&id)
}
pub fn main_load_recent_peers() { pub fn main_load_recent_peers() {
if !config::APP_DIR.read().unwrap().is_empty() { if !config::APP_DIR.read().unwrap().is_empty() {
let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(None) let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(None)
@ -883,8 +887,13 @@ pub fn main_load_recent_peers_sync() -> SyncReturn<String> {
pub fn main_load_recent_peers_for_ab(filter: String) -> String { pub fn main_load_recent_peers_for_ab(filter: String) -> String {
let id_filters = serde_json::from_str::<Vec<String>>(&filter).unwrap_or_default(); let id_filters = serde_json::from_str::<Vec<String>>(&filter).unwrap_or_default();
let id_filters = if id_filters.is_empty() {
None
} else {
Some(id_filters)
};
if !config::APP_DIR.read().unwrap().is_empty() { if !config::APP_DIR.read().unwrap().is_empty() {
let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(Some(id_filters)) let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(id_filters)
.drain(..) .drain(..)
.map(|(id, _, p)| peer_to_map_ab(id, p)) .map(|(id, _, p)| peer_to_map_ab(id, p))
.collect(); .collect();

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", "未成功获取地址簿"), ("pull_ab_failed_tip", "未成功获取地址簿"),
("push_ab_failed_tip", "未成功上传地址簿"), ("push_ab_failed_tip", "未成功上传地址簿"),
("synced_peer_readded_tip", "最近会话中存在的设备将会被重新添加到地址簿。"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", "Tags umschalten"), ("Toggle Tags", "Tags umschalten"),
("pull_ab_failed_tip", "Aktualisierung des Adressbuchs fehlgeschlagen"), ("pull_ab_failed_tip", "Aktualisierung des Adressbuchs fehlgeschlagen"),
("push_ab_failed_tip", "Synchronisierung des Adressbuchs mit dem Server fehlgeschlagen"), ("push_ab_failed_tip", "Synchronisierung des Adressbuchs mit dem Server fehlgeschlagen"),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -76,5 +76,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("exceed_max_devices", "You have reached the maximum number of managed devices."), ("exceed_max_devices", "You have reached the maximum number of managed devices."),
("pull_ab_failed_tip", "Failed to refresh address book"), ("pull_ab_failed_tip", "Failed to refresh address book"),
("push_ab_failed_tip", "Failed to sync address book to server"), ("push_ab_failed_tip", "Failed to sync address book to server"),
("synced_peer_readded_tip", "The devices present in the recent sessions will be re-added to the address book."),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", "Alternar Etiquetas"), ("Toggle Tags", "Alternar Etiquetas"),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", "Attiva/disattiva tag"), ("Toggle Tags", "Attiva/disattiva tag"),
("pull_ab_failed_tip", "Impossibile aggiornare la rubrica"), ("pull_ab_failed_tip", "Impossibile aggiornare la rubrica"),
("push_ab_failed_tip", "Impossibile sincronizzare la rubrica con il server"), ("push_ab_failed_tip", "Impossibile sincronizzare la rubrica con il server"),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", "Переключить метки"), ("Toggle Tags", "Переключить метки"),
("pull_ab_failed_tip", "Невозможно обновить адресную книгу"), ("pull_ab_failed_tip", "Невозможно обновить адресную книгу"),
("push_ab_failed_tip", "Невозможно синхронизировать адресную книгу с сервером"), ("push_ab_failed_tip", "Невозможно синхронизировать адресную книгу с сервером"),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", "未成功獲取地址簿"), ("pull_ab_failed_tip", "未成功獲取地址簿"),
("push_ab_failed_tip", "未成功上傳地址簿"), ("push_ab_failed_tip", "未成功上傳地址簿"),
("synced_peer_readded_tip", "最近會話中存在的設備將會被重新添加到地址簿。"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -537,5 +537,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Toggle Tags", ""), ("Toggle Tags", ""),
("pull_ab_failed_tip", ""), ("pull_ab_failed_tip", ""),
("push_ab_failed_tip", ""), ("push_ab_failed_tip", ""),
("synced_peer_readded_tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -648,6 +648,11 @@ pub fn peer_to_map_ab(id: String, p: PeerConfig) -> HashMap<&'static str, String
m m
} }
#[cfg(feature = "flutter")]
pub fn peer_exists(id: &str) -> bool {
PeerConfig::exists(id)
}
#[inline] #[inline]
pub fn get_lan_peers() -> Vec<HashMap<&'static str, String>> { pub fn get_lan_peers() -> Vec<HashMap<&'static str, String>> {
config::LanPeers::load() config::LanPeers::load()