mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-06-11 12:43:12 +08:00
sync ab alias
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
b2f5e2f927
commit
57b8ec178c
@ -159,7 +159,6 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
final greyStyle = TextStyle(
|
final greyStyle = TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6));
|
color: Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6));
|
||||||
final alias = bind.mainGetPeerOptionSync(id: peer.id, key: 'alias');
|
|
||||||
final child = Obx(
|
final child = Obx(
|
||||||
() => Container(
|
() => Container(
|
||||||
foregroundDecoration: deco.value,
|
foregroundDecoration: deco.value,
|
||||||
@ -196,7 +195,9 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
getOnline(8, peer.online),
|
getOnline(8, peer.online),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
alias.isEmpty ? formatID(peer.id) : alias,
|
peer.alias.isEmpty
|
||||||
|
? formatID(peer.id)
|
||||||
|
: peer.alias,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
)),
|
)),
|
||||||
@ -651,8 +652,13 @@ abstract class BasePeerCard extends StatelessWidget {
|
|||||||
oldName: oldName,
|
oldName: oldName,
|
||||||
onSubmit: (String newName) async {
|
onSubmit: (String newName) async {
|
||||||
if (newName != oldName) {
|
if (newName != oldName) {
|
||||||
await bind.mainSetPeerAlias(id: id, alias: newName);
|
if (tab == PeerTabIndex.ab) {
|
||||||
_update();
|
gFFI.abModel.changeAlias(id: id, alias: newName);
|
||||||
|
gFFI.abModel.pushAb();
|
||||||
|
} else {
|
||||||
|
await bind.mainSetPeerAlias(id: id, alias: newName);
|
||||||
|
_update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1050,6 +1056,11 @@ class AddressBookPeerCard extends BasePeerCard {
|
|||||||
dismissOnClicked: true,
|
dismissOnClicked: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
@override
|
||||||
|
Future<String> _getAlias(String id) async =>
|
||||||
|
gFFI.abModel.find(id)?.alias ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyGroupPeerCard extends BasePeerCard {
|
class MyGroupPeerCard extends BasePeerCard {
|
||||||
|
@ -197,6 +197,14 @@ class AbModel {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void changeAlias({required String id, required String alias}) {
|
||||||
|
final it = peers.where((element) => element.id == id);
|
||||||
|
if (it.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
it.first.alias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> pushAb({bool toast = true}) async {
|
Future<void> pushAb({bool toast = true}) async {
|
||||||
debugPrint("pushAb");
|
debugPrint("pushAb");
|
||||||
pushError.value = '';
|
pushError.value = '';
|
||||||
@ -332,7 +340,7 @@ class AbModel {
|
|||||||
username: r.username.isEmpty ? p.username : r.username,
|
username: r.username.isEmpty ? p.username : r.username,
|
||||||
hostname: r.hostname.isEmpty ? p.hostname : r.hostname,
|
hostname: r.hostname.isEmpty ? p.hostname : r.hostname,
|
||||||
platform: r.platform.isEmpty ? p.platform : r.platform,
|
platform: r.platform.isEmpty ? p.platform : r.platform,
|
||||||
alias: r.alias,
|
alias: p.alias.isEmpty ? r.alias : p.alias,
|
||||||
tags: p.tags,
|
tags: p.tags,
|
||||||
forceAlwaysRelay: r.forceAlwaysRelay,
|
forceAlwaysRelay: r.forceAlwaysRelay,
|
||||||
rdpPort: r.rdpPort,
|
rdpPort: r.rdpPort,
|
||||||
@ -352,7 +360,8 @@ class AbModel {
|
|||||||
return a.hash != b.hash ||
|
return a.hash != b.hash ||
|
||||||
a.username != b.username ||
|
a.username != b.username ||
|
||||||
a.platform != b.platform ||
|
a.platform != b.platform ||
|
||||||
a.hostname != b.hostname;
|
a.hostname != b.hostname ||
|
||||||
|
a.alias != b.alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Peer>> getRecentPeers() async {
|
Future<List<Peer>> getRecentPeers() async {
|
||||||
|
@ -56,6 +56,7 @@ class Peer {
|
|||||||
"username": username,
|
"username": username,
|
||||||
"hostname": hostname,
|
"hostname": hostname,
|
||||||
"platform": platform,
|
"platform": platform,
|
||||||
|
"alias": alias,
|
||||||
"tags": tags,
|
"tags": tags,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1499,6 +1499,12 @@ pub struct AbPeer {
|
|||||||
skip_serializing_if = "String::is_empty"
|
skip_serializing_if = "String::is_empty"
|
||||||
)]
|
)]
|
||||||
pub platform: String,
|
pub platform: String,
|
||||||
|
#[serde(
|
||||||
|
default,
|
||||||
|
deserialize_with = "deserialize_string",
|
||||||
|
skip_serializing_if = "String::is_empty"
|
||||||
|
)]
|
||||||
|
pub alias: String,
|
||||||
#[serde(default, deserialize_with = "deserialize_vec_string")]
|
#[serde(default, deserialize_with = "deserialize_vec_string")]
|
||||||
pub tags: Vec<String>,
|
pub tags: Vec<String>,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user