refact: optimize, loading recent peers (#10847)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-02-20 11:53:36 +08:00
committed by GitHub
parent 2e89a33210
commit 055b351164
8 changed files with 265 additions and 139 deletions

View File

@ -6,12 +6,13 @@ import 'package:flutter_hbb/models/platform_model.dart';
void showPeerSelectionDialog(
{bool singleSelection = false,
required Function(List<String>) onPeersCallback}) {
final peers = bind.mainLoadRecentPeersSync();
required Function(List<String>) onPeersCallback}) async {
final peers = await bind.mainGetRecentPeers(getAll: true);
if (peers.isEmpty) {
debugPrint("load recent peers sync failed.");
debugPrint("load recent peers failed.");
return;
}
Map<String, dynamic> map = jsonDecode(peers);
List<dynamic> peersList = map['peers'] ?? [];
final selected = List<String>.empty(growable: true);