mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
ab: read respectively and sync when set
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -122,6 +122,10 @@ class AbModel {
|
||||
}
|
||||
}
|
||||
|
||||
Peer? find(String id) {
|
||||
return peers.firstWhereOrNull((e) => e.id == id);
|
||||
}
|
||||
|
||||
bool idContainBy(String id) {
|
||||
return peers.where((element) => element.id == id).isNotEmpty;
|
||||
}
|
||||
@@ -160,13 +164,28 @@ class AbModel {
|
||||
}
|
||||
}
|
||||
|
||||
void setPeerAlias(String id, String value) {
|
||||
Future<void> setPeerAlias(String id, String value) async {
|
||||
final it = peers.where((p0) => p0.id == id);
|
||||
if (it.isEmpty) {
|
||||
debugPrint("$id is not exists");
|
||||
return;
|
||||
} else {
|
||||
if (it.isNotEmpty) {
|
||||
it.first.alias = value;
|
||||
await pushAb();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setPeerForceAlwaysRelay(String id, bool value) async {
|
||||
final it = peers.where((p0) => p0.id == id);
|
||||
if (it.isNotEmpty) {
|
||||
it.first.forceAlwaysRelay = value;
|
||||
await pushAb();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setRdp(String id, String port, String username) async {
|
||||
final it = peers.where((p0) => p0.id == id);
|
||||
if (it.isNotEmpty) {
|
||||
it.first.rdpPort = port;
|
||||
it.first.rdpUsername = username;
|
||||
await pushAb();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ class Peer {
|
||||
final String platform;
|
||||
String alias;
|
||||
List<dynamic> tags;
|
||||
bool forceAlwaysRelay = false;
|
||||
String rdpPort;
|
||||
String rdpUsername;
|
||||
bool online = false;
|
||||
|
||||
Peer.fromJson(Map<String, dynamic> json)
|
||||
@@ -17,7 +20,10 @@ class Peer {
|
||||
hostname = json['hostname'] ?? '',
|
||||
platform = json['platform'] ?? '',
|
||||
alias = json['alias'] ?? '',
|
||||
tags = json['tags'] ?? [];
|
||||
tags = json['tags'] ?? [],
|
||||
forceAlwaysRelay = json['forceAlwaysRelay'] == 'true',
|
||||
rdpPort = json['rdpPort'] ?? '',
|
||||
rdpUsername = json['rdpUsername'] ?? '';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return <String, dynamic>{
|
||||
@@ -27,6 +33,9 @@ class Peer {
|
||||
"platform": platform,
|
||||
"alias": alias,
|
||||
"tags": tags,
|
||||
"forceAlwaysRelay": forceAlwaysRelay.toString(),
|
||||
"rdpPort": rdpPort,
|
||||
"rdpUsername": rdpUsername,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,16 +46,23 @@ class Peer {
|
||||
required this.platform,
|
||||
required this.alias,
|
||||
required this.tags,
|
||||
required this.forceAlwaysRelay,
|
||||
required this.rdpPort,
|
||||
required this.rdpUsername,
|
||||
});
|
||||
|
||||
Peer.loading()
|
||||
: this(
|
||||
id: '...',
|
||||
username: '...',
|
||||
hostname: '...',
|
||||
platform: '...',
|
||||
alias: '',
|
||||
tags: []);
|
||||
id: '...',
|
||||
username: '...',
|
||||
hostname: '...',
|
||||
platform: '...',
|
||||
alias: '',
|
||||
tags: [],
|
||||
forceAlwaysRelay: false,
|
||||
rdpPort: '',
|
||||
rdpUsername: '',
|
||||
);
|
||||
}
|
||||
|
||||
class Peers extends ChangeNotifier {
|
||||
|
||||
Reference in New Issue
Block a user