Skip to content

Commit

Permalink
use of Option in StoreWakuMessageResponse for responses with or witho…
Browse files Browse the repository at this point in the history
…ug msgs
  • Loading branch information
Ivansete-status committed Jan 9, 2025
1 parent bbcf401 commit f1e4e02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions examples/toy-chat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ impl App<Running> {
Some(time_start),
None,
None).await.unwrap();
let messages:Vec<_> = messages
.iter()
.map(|store_resp_msg| {
<Chat2Message as Message>::decode(store_resp_msg.message.payload())
.expect("Toy chat messages should be decodeable")
})
.collect();

let messages: Vec<_> = messages
.into_iter()
// we expect messages because the query was passed with include_data == true
.filter(|item| item.message.is_some())
.map(|store_resp_msg| {
<Chat2Message as Message>::decode(store_resp_msg.message.unwrap().payload())
.expect("Toy chat messages should be decodeable")
})
.collect();

if !messages.is_empty() {
*self.messages.write().unwrap() = messages;
Expand Down
2 changes: 1 addition & 1 deletion waku-bindings/src/node/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl StoreQueryRequest {
#[serde(rename_all = "camelCase")]
pub struct StoreWakuMessageResponse {
pub message_hash: MessageHash,
pub message: WakuStoreRespMessage,
pub message: Option<WakuStoreRespMessage>, // None if include_data == false
pub pubsub_topic: String,
}

Expand Down

0 comments on commit f1e4e02

Please sign in to comment.