diff --git a/src/commands/mod.rs b/src/commands/mod.rs index b5137cf..63a2311 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -166,18 +166,19 @@ fn fetch_all() -> CommandResult { for (name, mut account_config) in config.into_iter() { log::debug!("Fetching new items from {:?}", name); let new_top_favourite = fetch_account_favourites(&mut account_config)?; - // // XXX implement - // // config.set_new_favourite(new_top_favourite); + config.set_new_favourite(name, &new_top_favourite); } config.save()?; Ok(()) } -fn fetch_account(account: &str) -> CommandResult { +fn fetch_account(_account: &str) -> CommandResult { Ok(()) } -fn fetch_account_favourites(account: &mut AccountConfig) -> CommandResult { +fn fetch_account_favourites( + account: &mut AccountConfig, +) -> Result { // XXX before anything, we could check if there is any storage enabled. // XXX we could create a list of storages, so after retrieving the toot // and converting to our format, we just go through this list and call @@ -194,7 +195,7 @@ fn fetch_account_favourites(account: &mut AccountConfig) -> CommandResult { most_recent = Some((&toot.id).into()); } - let conversion = Data::from(&toot); + let _conversion = Data::from(&toot); // XXX storage here // storage.save(&conversion) @@ -202,6 +203,6 @@ fn fetch_account_favourites(account: &mut AccountConfig) -> CommandResult { Ok(()) } -fn sync_account(account: &str) -> CommandResult { +fn sync_account(_account: &str) -> CommandResult { Ok(()) } diff --git a/src/config/account.rs b/src/config/account.rs index 67000ef..a875023 100644 --- a/src/config/account.rs +++ b/src/config/account.rs @@ -52,6 +52,11 @@ impl AccountConfig { self.favourite.last() } + #[logfn_inputs(Trace)] + pub fn set_favourite(&mut self, favourite: &str) { + self.favourite.set(favourite); + } + /// The Mastodon configuration for the account. pub fn mastodon(&self) -> Data { self.mastodon.clone() diff --git a/src/config/favourite.rs b/src/config/favourite.rs index 3a4f92d..880ecde 100644 --- a/src/config/favourite.rs +++ b/src/config/favourite.rs @@ -26,7 +26,7 @@ pub struct Favourite { } impl Favourite { - /// Return the last favourite + /// Return the last favourite. /// /// For example, if there is a favourite ID, returns it. /// @@ -47,4 +47,9 @@ impl Favourite { None => "0".into(), } } + + /// Set the last seen favourite. + pub fn set(&mut self, last: &str) { + self.last = Some(last.into()); + } }