Remove KVT to Value map and retrieve sequence number directly from KVT
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
9704269c8a
commit
eddb167c4c
|
@ -8,12 +8,11 @@ use std::{
|
|||
process::{Command, Output},
|
||||
};
|
||||
|
||||
use async_std::stream::StreamExt;
|
||||
use async_std::task;
|
||||
use dirs;
|
||||
use futures::stream::TryStreamExt;
|
||||
use golgi::{
|
||||
api::friends::RelationshipQuery, blobs, messages::SsbMessageValue, sbot::Keystore, Sbot,
|
||||
api::friends::RelationshipQuery, blobs, messages::SsbMessageKVT, sbot::Keystore, Sbot,
|
||||
};
|
||||
use log::debug;
|
||||
use peach_lib::config_manager;
|
||||
|
@ -135,11 +134,7 @@ pub fn latest_sequence_number() -> Result<u64, Box<dyn Error>> {
|
|||
let id = sbot_client.whoami().await?;
|
||||
|
||||
let history_stream = sbot_client.create_history_stream(id).await?;
|
||||
let msg_stream = history_stream.map(|res| match res {
|
||||
Ok(kvt) => Ok(kvt.value),
|
||||
Err(err) => Err(err),
|
||||
});
|
||||
let mut msgs: Vec<SsbMessageValue> = msg_stream.try_collect().await?;
|
||||
let mut msgs: Vec<SsbMessageKVT> = history_stream.try_collect().await?;
|
||||
|
||||
// there will be zero messages when the sbot is run for the first time
|
||||
if msgs.is_empty() {
|
||||
|
@ -149,7 +144,7 @@ pub fn latest_sequence_number() -> Result<u64, Box<dyn Error>> {
|
|||
msgs.reverse();
|
||||
|
||||
// return the sequence number of the latest msg
|
||||
Ok(msgs[0].sequence)
|
||||
Ok(msgs[0].value.sequence)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue