mirror of
https://github.com/jwinterm/grim.git
synced 2026-10-22 15:58:32 +02:00
ui: wallet connection selector/creator modal, separate modal content for connection creation, move settings into wallet
This commit is contained in:
@@ -102,11 +102,11 @@ impl ConnectionsConfig {
|
||||
}
|
||||
|
||||
/// Set [`ExternalConnection`] availability flag.
|
||||
pub fn update_ext_conn_availability(id: i64, available: bool) {
|
||||
pub fn update_ext_conn_status(id: i64, available: Option<bool>) {
|
||||
let mut w_config = Settings::conn_config_to_update();
|
||||
for c in w_config.external.iter_mut() {
|
||||
if c.id == id {
|
||||
c.available = Some(available);
|
||||
c.available = available;
|
||||
w_config.save();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ impl ExternalConnection {
|
||||
|
||||
/// Check connection availability.
|
||||
fn check_conn_availability(&self) {
|
||||
// Check every connection at separate thread.
|
||||
let conn = self.clone();
|
||||
ConnectionsConfig::update_ext_conn_status(conn.id, None);
|
||||
std::thread::spawn(move || {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
@@ -84,29 +84,33 @@ impl ExternalConnection {
|
||||
let status = res.status().as_u16();
|
||||
// Available on 200 HTTP status code.
|
||||
if status == 200 {
|
||||
ConnectionsConfig::update_ext_conn_availability(conn.id, true);
|
||||
ConnectionsConfig::update_ext_conn_status(conn.id, Some(true));
|
||||
} else {
|
||||
ConnectionsConfig::update_ext_conn_availability(conn.id, false);
|
||||
ConnectionsConfig::update_ext_conn_status(conn.id, Some(false));
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
ConnectionsConfig::update_ext_conn_availability(conn.id, false);
|
||||
ConnectionsConfig::update_ext_conn_status(conn.id, Some(false));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConnectionsConfig::update_ext_conn_availability(conn.id, false);
|
||||
ConnectionsConfig::update_ext_conn_status(conn.id, Some(false));
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// Check external connections availability at another thread.
|
||||
pub fn start_ext_conn_availability_check() {
|
||||
/// Check external connections availability.
|
||||
pub fn check_ext_conn_availability(id: Option<i64>) {
|
||||
let conn_list = ConnectionsConfig::ext_conn_list();
|
||||
for conn in conn_list {
|
||||
// Check every connection at separate thread.
|
||||
conn.check_conn_availability();
|
||||
if let Some(id) = id {
|
||||
if id == conn.id {
|
||||
conn.check_conn_availability();
|
||||
}
|
||||
} else {
|
||||
conn.check_conn_availability();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user