aboutsummaryrefslogtreecommitdiff
path: root/src/commands/fav.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/fav.rs')
-rw-r--r--src/commands/fav.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/commands/fav.rs b/src/commands/fav.rs
index e823618..0bee8ce 100644
--- a/src/commands/fav.rs
+++ b/src/commands/fav.rs
@@ -1,3 +1,4 @@
+use display::DisplayInfo;
use tw;
use ::Queryer;
@@ -16,25 +17,25 @@ pub static UNFAV: Command = Command {
help_str: "Unfavorite a tweet."
};
-fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, display_info: &mut DisplayInfo) {
let maybe_id = TweetId::parse(line.to_owned());
match maybe_id {
Ok(twid) => {
- if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self
+ if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self
let result = match tweeter.current_profile() {
Some(user_profile) => queryer.do_api_post(&format!("{}?id={}", UNFAV_TWEET_URL, twete.id), &tweeter.app_key, &user_profile.creds),
None => Err("No logged in user to unfav from".to_owned())
};
match result {
Ok(_) => (),
- Err(e) => tweeter.display_info.status(e)
+ Err(e) => display_info.status(e)
}
} else {
- tweeter.display_info.status(format!("No tweet for id: {:?}", twid));
+ display_info.status(format!("No tweet for id: {:?}", twid));
}
}
Err(e) => {
- tweeter.display_info.status(format!("Invalid id: {}", e));
+ display_info.status(format!("Invalid id: {}", e));
}
}
}
@@ -47,26 +48,26 @@ pub static FAV: Command = Command {
help_str: "Favorite a tweet."
};
-fn fav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+fn fav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, display_info: &mut DisplayInfo) {
let maybe_id = TweetId::parse(line.to_owned());
match maybe_id {
Ok(twid) => {
// tweeter.to_twitter_tweet_id(twid)...
- if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self
+ if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self
let result = match tweeter.current_profile() {
Some(user_profile) => queryer.do_api_post(&format!("{}?id={}", FAV_TWEET_URL, twete.id), &tweeter.app_key, &user_profile.creds),
None => Err("No logged in user to fav from".to_owned())
};
match result {
Ok(_) => (),
- Err(e) => tweeter.display_info.status(e)
+ Err(e) => display_info.status(e)
}
} else {
- tweeter.display_info.status(format!("No tweet for id: {:?}", twid));
+ display_info.status(format!("No tweet for id: {:?}", twid));
}
}
Err(e) => {
- tweeter.display_info.status(format!("Invalid id: {}", e));
+ display_info.status(format!("Invalid id: {}", e));
}
}
}