fix: Last contact list edit: default to now if unset

This commit is contained in:
Mike Dilger 2023-09-14 10:45:19 +12:00
parent 0986d574a6
commit d82be4b91c
2 changed files with 8 additions and 5 deletions

View File

@ -531,12 +531,16 @@ impl Storage {
Ok(())
}
pub fn read_last_contact_list_edit(&self) -> Result<Option<i64>, Error> {
pub fn read_last_contact_list_edit(&self) -> Result<i64, Error> {
let txn = self.env.read_txn()?;
match self.general.get(&txn, b"last_contact_list_edit")? {
None => Ok(None),
Some(bytes) => Ok(Some(i64::from_be_bytes(bytes[..8].try_into().unwrap()))),
None => {
let now = Unixtime::now().unwrap();
self.write_last_contact_list_edit(now.0, None)?;
Ok(now.0)
}
Some(bytes) => Ok(i64::from_be_bytes(bytes[..8].try_into().unwrap())),
}
}

View File

@ -115,8 +115,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
ui.add_space(10.0);
let last_contact_list_edit = match GLOBALS.storage.read_last_contact_list_edit() {
Ok(Some(date)) => date,
Ok(None) => 0,
Ok(date) => date,
Err(e) => {
tracing::error!("{}", e);
0