chore: fix missing message during initial fetch (#110)
* remove fetched flag * . * improve
This commit is contained in:
@@ -36,20 +36,21 @@ pub const NOSTR_CONNECT_RELAY: &str = "wss://relay.nsec.app";
|
||||
/// Default timeout (in seconds) for Nostr Connect
|
||||
pub const NOSTR_CONNECT_TIMEOUT: u64 = 200;
|
||||
|
||||
/// Unique ID for new message subscription.
|
||||
pub const NEW_MESSAGE_ID: &str = "listen_new_giftwraps";
|
||||
/// Unique ID for all messages subscription.
|
||||
pub const ALL_MESSAGES_ID: &str = "listen_all_giftwraps";
|
||||
/// Unique ID for all newest messages subscription.
|
||||
pub const ALL_NEWEST_MESSAGES_ID: &str = "listen_all_newest_giftwraps";
|
||||
/// Unique ID for all gift wraps subscription.
|
||||
pub const GIFT_WRAP_SUB_ID: &str = "listen_for_giftwraps";
|
||||
|
||||
/// Total metadata requests will be grouped.
|
||||
pub const METADATA_BATCH_LIMIT: usize = 100;
|
||||
|
||||
/// Maximum timeout for grouping metadata requests.
|
||||
pub const METADATA_BATCH_TIMEOUT: u64 = 400;
|
||||
|
||||
/// Maximum timeout for waiting for finish (seconds)
|
||||
pub const WAIT_FOR_FINISH: u64 = 60;
|
||||
|
||||
/// Default width for all modals.
|
||||
pub const DEFAULT_MODAL_WIDTH: f32 = 420.;
|
||||
|
||||
/// Default width of the sidebar.
|
||||
pub const DEFAULT_SIDEBAR_WIDTH: f32 = 280.;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use nostr_connect::prelude::*;
|
||||
use nostr_sdk::prelude::*;
|
||||
use paths::nostr_file;
|
||||
|
||||
use crate::constants::GIFT_WRAP_SUB_ID;
|
||||
use crate::paths::support_dir;
|
||||
|
||||
pub mod constants;
|
||||
@@ -33,6 +34,8 @@ pub enum NostrSignal {
|
||||
}
|
||||
|
||||
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
|
||||
static GIFT_WRAP_ID: OnceLock<SubscriptionId> = OnceLock::new();
|
||||
static CURRENT_TIMESTAMP: OnceLock<Timestamp> = OnceLock::new();
|
||||
static FIRST_RUN: OnceLock<bool> = OnceLock::new();
|
||||
|
||||
pub fn nostr_client() -> &'static Client {
|
||||
@@ -61,6 +64,14 @@ pub fn nostr_client() -> &'static Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn gift_wrap_sub_id() -> &'static SubscriptionId {
|
||||
GIFT_WRAP_ID.get_or_init(|| SubscriptionId::new(GIFT_WRAP_SUB_ID))
|
||||
}
|
||||
|
||||
pub fn starting_time() -> &'static Timestamp {
|
||||
CURRENT_TIMESTAMP.get_or_init(Timestamp::now)
|
||||
}
|
||||
|
||||
pub fn first_run() -> &'static bool {
|
||||
FIRST_RUN.get_or_init(|| {
|
||||
let flag = support_dir().join(format!(".{}-first_run", env!("CARGO_PKG_VERSION")));
|
||||
@@ -75,16 +86,3 @@ pub fn first_run() -> &'static bool {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn set_all_gift_wraps_fetched() {
|
||||
let flag = support_dir().join(".fetched");
|
||||
|
||||
if !flag.exists() && smol::fs::write(&flag, "").await.is_err() {
|
||||
log::error!("Failed to create full run flag");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_gift_wraps_fetch_complete() -> bool {
|
||||
let flag = support_dir().join(".fetched");
|
||||
flag.exists()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user