From 7070bbb77b23d181c37cf48acebfb3bdce1ddf87 Mon Sep 17 00:00:00 2001 From: creating2morrow Date: Mon, 1 May 2023 00:14:30 -0400 Subject: [PATCH] disallow composing on offline contact --- nevmes-core/src/utils.rs | 4 ++-- nevmes-gui/README.md | 5 ++++- nevmes-gui/src/apps/address_book.rs | 12 +++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/nevmes-core/src/utils.rs b/nevmes-core/src/utils.rs index 13e0fba..924223b 100644 --- a/nevmes-core/src/utils.rs +++ b/nevmes-core/src/utils.rs @@ -1,7 +1,7 @@ use rand_core::RngCore; use clap::Parser; use rocket::serde::json::Json; -use crate::{args, db, i2p, message, models, monero, gpg, utils, reqres}; +use crate::{args, db, i2p, models, monero, gpg, utils, reqres}; use log::{info, debug, error, warn}; use std::time::Duration; @@ -317,7 +317,7 @@ pub async fn start_up() { gen_app_gpg().await; let env: String = get_release_env().value(); start_gui(); - { tokio::spawn(async { message::retry_fts().await; }); } + // { tokio::spawn(async { message::retry_fts().await; }); } info!("{} - nevmes is online", env); } diff --git a/nevmes-gui/README.md b/nevmes-gui/README.md index 4f6448e..40625e9 100644 --- a/nevmes-gui/README.md +++ b/nevmes-gui/README.md @@ -1,4 +1,7 @@ ## Dev -`cd ../ && cargo build && cd nevmes-gui && RUST_LOG=debug cargo run` +Note: gui depends on the binary if starting core from gui +otherwise run nevmes core on your own + +`cd ../ && cargo build && cp target/debug/nevmes nevmes-gui/ && cd nevmes-gui && RUST_LOG=debug cargo run` \ No newline at end of file diff --git a/nevmes-gui/src/apps/address_book.rs b/nevmes-gui/src/apps/address_book.rs index 71e6539..5df4900 100644 --- a/nevmes-gui/src/apps/address_book.rs +++ b/nevmes-gui/src/apps/address_book.rs @@ -159,6 +159,14 @@ impl eframe::App for AddressBookApp { self.approve_contact = true; } if self.showing_status { + let i2p_address = self.s_contact.i2p_address.clone(); + if self.s_contact.xmr_address == utils::empty_string() { + clear_gui_db(String::from("gui-online"), String::from(&i2p_address)); + write_gui_db(String::from("gui-online"), String::from(&i2p_address), String::from("0")); + } else { + clear_gui_db(String::from("gui-online"), String::from(&i2p_address)); + write_gui_db(String::from("gui-online"), String::from(&i2p_address), String::from("1")); + } self.is_pinging = false; } } @@ -490,9 +498,11 @@ impl eframe::App for AddressBookApp { Ok(n) => n, Err(_e) => 0, }; + let is_online_now = search_gui_db(String::from("gui-online"), String::from(&c.i2p_address)); if now < expire && self.status.signed_key && self.status.jwp != utils::empty_string() - && c.i2p_address == self.status.i2p { + && c.i2p_address == self.status.i2p + && is_online_now == String::from("1") { if ui.button("Compose").clicked() { self.is_composing = true; }