remove Instant sub (#8714)

which cause crash when connect to windows just startup

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-07-15 10:49:09 +08:00
committed by GitHub
parent 8512c2b2b0
commit 3f11d9cdb6
3 changed files with 18 additions and 10 deletions

View File

@@ -283,7 +283,7 @@ async fn handle_received_peers(mut rx: UnboundedReceiver<config::DiscoveryPeer>)
});
let mut response_set = HashSet::new();
let mut last_write_time = Instant::now() - std::time::Duration::from_secs(4);
let mut last_write_time: Option<Instant> = None;
loop {
tokio::select! {
data = rx.recv() => match data {
@@ -297,11 +297,11 @@ async fn handle_received_peers(mut rx: UnboundedReceiver<config::DiscoveryPeer>)
}
}
peers.insert(0, peer);
if last_write_time.elapsed().as_millis() > 300 {
if last_write_time.map(|t| t.elapsed().as_millis() > 300).unwrap_or(true) {
config::LanPeers::store(&peers);
#[cfg(feature = "flutter")]
crate::flutter_ffi::main_load_lan_peers();
last_write_time = Instant::now();
last_write_time = Some(Instant::now());
}
}
None => {