mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 22:57:59 -05:00
wallet: force recent messages to always appear sequential
This commit is contained in:
@@ -62,6 +62,10 @@ const EVGRDB_PATH: &str = "~/.local/darkfi/darkwallet/evgr/";
|
||||
const ENDPOINT: &str = "tcp://agorism.dev:5588";
|
||||
const CHANNEL: &str = "#random";
|
||||
|
||||
/// Due to drift between different machine's clocks, if the message timestamp is recent
|
||||
/// then we will just correct it to the current time so messages appear sequential in the UI.
|
||||
const RECENT_TIME_DIST: u64 = 10;
|
||||
|
||||
#[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
|
||||
pub struct Privmsg {
|
||||
pub channel: String,
|
||||
@@ -320,6 +324,12 @@ impl LocalDarkIRC {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
// This is a hack to make messages appear sequentially in the UI
|
||||
let now_timest = UNIX_EPOCH.elapsed().unwrap().as_millis() as u64;
|
||||
if timest.abs_diff(now_timest) < RECENT_TIME_DIST {
|
||||
timest = now_timest;
|
||||
}
|
||||
|
||||
let mut arg_data = vec![];
|
||||
timest.encode_async(&mut arg_data).await.unwrap();
|
||||
ev.id().as_bytes().encode_async(&mut arg_data).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user