From 3c042afe7872d5488fd91c2b1a42036953f604eb Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Thu, 30 Nov 2017 03:07:05 -0800 Subject: remove unneeded params, adjust id display tweets are now recorded with the date they are recieved at dated id lookup is now supported tweet ids, where displayed, are displayed in a convenient form: if the tweet was recieved today, show the today id if the tweet was recieved on a different day, show the bare id many instances where display_info was passed for logging information, the parameter has become unnecessary, so it's gone now --- src/commands/fav.rs | 4 ++-- src/commands/thread.rs | 2 +- src/commands/twete.rs | 14 +++++++------- src/commands/view.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/commands') diff --git a/src/commands/fav.rs b/src/commands/fav.rs index 0bee8ce..5e5f2a2 100644 --- a/src/commands/fav.rs +++ b/src/commands/fav.rs @@ -21,7 +21,7 @@ fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, di let maybe_id = TweetId::parse(line.to_owned()); match maybe_id { Ok(twid) => { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self + if let Some(twete) = tweeter.retrieve_tweet(&twid).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()) @@ -53,7 +53,7 @@ fn fav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp match maybe_id { Ok(twid) => { // tweeter.to_twitter_tweet_id(twid)... - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self + if let Some(twete) = tweeter.retrieve_tweet(&twid).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()) diff --git a/src/commands/thread.rs b/src/commands/thread.rs index 302e641..f82fb13 100644 --- a/src/commands/thread.rs +++ b/src/commands/thread.rs @@ -38,7 +38,7 @@ fn remember(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer let maybe_id = TweetId::parse(line.to_owned()); match maybe_id { Ok(twid) => { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { + if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { tweeter.set_thread(name.to_string(), twete.internal_id); display_info.status(format!("Ok! Recorded {:?} as thread {}", twid, name)); } else { diff --git a/src/commands/twete.rs b/src/commands/twete.rs index ac4bbeb..ebf3c3d 100644 --- a/src/commands/twete.rs +++ b/src/commands/twete.rs @@ -22,7 +22,7 @@ fn del(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp match TweetId::parse(line.clone()) { Ok(twid) => { // TODO this really converts twid to a TweetId::Twitter - if let Some(twitter_id) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.id.to_owned()) { + if let Some(twitter_id) = tweeter.retrieve_tweet(&twid).map(|x| x.id.to_owned()) { let result = match tweeter.current_profile() { Some(user_profile) => queryer.do_api_post(&format!("{}/{}.json", DEL_TWEET_URL, twitter_id), &tweeter.app_key, &user_profile.creds), None => Err("No logged in user to delete as".to_owned()) @@ -100,7 +100,7 @@ fn thread(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, d let maybe_id = TweetId::parse(id_str.to_owned()); match maybe_id { Ok(twid) => { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self + if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self let handle = &tweeter.retrieve_user(&twete.author_id).unwrap().handle.to_owned(); // TODO: definitely breaks if you change your handle right now if handle == &user_profile.user.handle { @@ -152,13 +152,13 @@ fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp let maybe_id = TweetId::parse(id_str.to_owned()); match maybe_id { Ok(twid) => { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self + if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self // get handles to reply to... let author_handle = tweeter.retrieve_user(&twete.author_id).unwrap().handle.to_owned(); let mut ats: Vec = twete.get_mentions(); //std::collections::HashSet::new(); ats.remove_item(&author_handle); ats.insert(0, author_handle); - if let Some(rt_tweet) = twete.rt_tweet.and_then(|id| tweeter.retrieve_tweet(&TweetId::Twitter(id), display_info)).map(|x| x.clone()) { + if let Some(rt_tweet) = twete.rt_tweet.and_then(|id| tweeter.retrieve_tweet(&TweetId::Twitter(id))).map(|x| x.clone()) { let rt_author_handle = tweeter.retrieve_user(&rt_tweet.author_id).unwrap().handle.to_owned(); ats.remove_item(&rt_author_handle); ats.insert(1, rt_author_handle); @@ -191,7 +191,7 @@ fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp } pub fn send_reply(text: String, twid: TweetId, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, user_creds: tw::Credential, display_info: &mut DisplayInfo) { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self + if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self let substituted = ::url_encode(&text); let result = match tweeter.current_profile() { Some(user_profile) => { @@ -226,7 +226,7 @@ fn quote(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, di let maybe_id = TweetId::parse(id_str.to_owned()); match maybe_id { Ok(twid) => { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self + if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self let substituted = ::url_encode(reply); let attachment_url = ::url_encode( &format!( @@ -281,7 +281,7 @@ fn retwete(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, match TweetId::parse(line.clone()) { Ok(twid) => { // TODO this really converts twid to a TweetId::Twitter - if let Some(twitter_id) = tweeter.retrieve_tweet(&twid, display_info).map(|x| x.id.to_owned()) { + if let Some(twitter_id) = tweeter.retrieve_tweet(&twid).map(|x| x.id.to_owned()) { let result = match tweeter.current_profile() { Some(user_profile) => { queryer.do_api_post(&format!("{}/{}.json", RT_TWEET_URL, twitter_id), &tweeter.app_key, &user_profile.creds) diff --git a/src/commands/view.rs b/src/commands/view.rs index 41dd9b3..18ba871 100644 --- a/src/commands/view.rs +++ b/src/commands/view.rs @@ -19,7 +19,7 @@ pub static VIEW: Command = Command { fn view(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer, display_info: &mut DisplayInfo) { match TweetId::parse(line) { Ok(twid) => { - if let Some(twete) = tweeter.retrieve_tweet(&twid, display_info) { + if let Some(twete) = tweeter.retrieve_tweet(&twid) { display_info.recv(display::Infos::TweetWithContext( TweetId::Twitter(twete.id.to_owned()), format!("link: https://twitter.com/i/web/status/{}", twete.id) -- cgit v1.1