Polish chat and add necessary fixes

This commit is contained in:
Daniel Sanchez Quiros 2022-10-19 12:26:16 +02:00
parent 70fb6ebd3c
commit 0d399e542f
3 changed files with 14 additions and 6 deletions

View File

@ -23,8 +23,8 @@ use tui::{
};
use unicode_width::UnicodeWidthStr;
use waku::{
waku_new, waku_set_event_callback, ContentFilter, Multiaddr, ProtocolId, Running, StoreQuery,
WakuMessage, WakuNodeHandle,
waku_new, waku_set_event_callback, ContentFilter, Multiaddr, PagingOptions, ProtocolId,
Running, StoreQuery, WakuMessage, WakuNodeHandle,
};
enum InputMode {
@ -78,10 +78,14 @@ fn retrieve_history(node_handle: &WakuNodeHandle<Running>) -> waku::Result<Vec<C
start_time: Some(
(Duration::from_secs(Utc::now().timestamp() as u64)
- Duration::from_secs(60 * 60 * 24))
.as_secs() as usize,
.as_nanos() as usize,
),
end_time: None,
paging_options: None,
paging_options: Some(PagingOptions {
page_size: 25,
cursor: None,
forward: true,
}),
},
peer.peer_id(),
Some(Duration::from_secs(10)),
@ -137,9 +141,11 @@ fn main() -> std::result::Result<(), Box<dyn Error>> {
}
}
}
_ => {
unreachable!()
waku::Event::Unrecognized(data) => {
let mut out = std::io::stderr();
write!(out, "Error, received unrecognized event {data}").unwrap();
}
_ => {}
});
// app.node_handle.relay_publish_message(&WakuMessage::new(Chat2Message::new(&app.nick, format!(""))))

View File

@ -38,6 +38,7 @@ impl Signal {
#[serde(untagged, rename_all = "camelCase")]
pub enum Event {
WakuMessage(WakuMessageEvent),
Unrecognized(serde_json::Value),
}
/// Type of `event` field for a `message` event

View File

@ -239,6 +239,7 @@ pub struct StoreQuery {
#[serde(rename_all = "camelCase")]
pub struct StoreResponse {
/// Array of retrieved historical messages in [`WakuMessage`] format
#[serde(default)]
messages: Vec<WakuMessage>,
/// Paging information in [`PagingOptions`] format from which to resume further historical queries
paging_options: Option<PagingOptions>,