Skip to content

Commit

Permalink
delete discovery from RustDesk_lan_peers.toml
Browse files Browse the repository at this point in the history
Signed-off-by: 21pages <[email protected]>
  • Loading branch information
21pages committed Feb 24, 2023
1 parent ca991ff commit 920477b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
8 changes: 6 additions & 2 deletions flutter/lib/common/widgets/peer_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ abstract class BasePeerCard extends StatelessWidget {
proc: () {
() async {
if (isLan) {
// TODO
bind.mainRemoveDiscovered(id: id);
} else {
final favs = (await bind.mainGetFav()).toList();
if (favs.remove(id)) {
Expand Down Expand Up @@ -859,7 +859,11 @@ class DiscoveredPeerCard extends BasePeerCard {
}

menuItems.add(MenuEntryDivider());
menuItems.add(_removeAction(peer.id, () async {}));
menuItems.add(
_removeAction(peer.id, () async {
await bind.mainLoadLanPeers();
}, isLan: true),
);
return menuItems;
}

Expand Down
4 changes: 4 additions & 0 deletions src/flutter_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,10 @@ pub fn main_load_lan_peers() {
};
}

pub fn main_remove_discovered(id: String) {
remove_discovered(id);
}

fn main_broadcast_message(data: &HashMap<&str, &str>) {
let apps = vec![
flutter::APP_TYPE_DESKTOP_REMOTE,
Expand Down
4 changes: 1 addition & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@ impl UI {
}

fn remove_discovered(&mut self, id: String) {
let mut peers = config::LanPeers::load().peers;
peers.retain(|x| x.id != id);
config::LanPeers::store(&peers);
remove_discovered(id);
}

fn send_wol(&mut self, id: String) {
Expand Down
7 changes: 7 additions & 0 deletions src/ui_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,13 @@ pub fn get_lan_peers() -> Vec<HashMap<&'static str, String>> {
.collect()
}

#[inline]
pub fn remove_discovered(id: String) {
let mut peers = config::LanPeers::load().peers;
peers.retain(|x| x.id != id);
config::LanPeers::store(&peers);
}

#[inline]
pub fn get_uuid() -> String {
base64::encode(hbb_common::get_uuid())
Expand Down

0 comments on commit 920477b

Please sign in to comment.