Browse Source

Set favourite

master
Julio Biason 3 years ago
parent
commit
90dba310fa
  1. 13
      src/commands/mod.rs
  2. 5
      src/config/account.rs
  3. 7
      src/config/favourite.rs

13
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<String, CommandError> {
// 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(())
}

5
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()

7
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());
}
}

Loading…
Cancel
Save