diff options
author | iximeow <me@iximeow.net> | 2017-12-24 23:11:19 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-12-24 23:11:19 -0800 |
commit | 9df06af16276e3c002516836b4851be4e6e6c993 (patch) | |
tree | cffb070e4cef1baa71d968143bec5925cdbe92af | |
parent | 04072d36a1597e66d8034c98c30b76caf52c299b (diff) | |
parent | 023e4bc607760528e96d7e11214d9223ad4ff616 (diff) |
Merge branch 'master' of github.com:iximeow/reifenfeuerd
-rw-r--r-- | src/commands/twete.rs | 31 | ||||
-rw-r--r-- | src/display/mod.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 1 |
3 files changed, 20 insertions, 14 deletions
diff --git a/src/commands/twete.rs b/src/commands/twete.rs index d727b9e..450c225 100644 --- a/src/commands/twete.rs +++ b/src/commands/twete.rs @@ -155,24 +155,31 @@ fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp 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<String> = twete.get_mentions(); //std::collections::HashSet::new(); - ats.remove_item(&author_handle); - ats.insert(0, author_handle); + let raw_ats: Vec<String> = twete.get_mentions(); //std::collections::HashSet::new(); + let mut reordered_ats: Vec<String> = Vec::new(); + if &author_handle != &user_profile.user.handle { + reordered_ats.push(author_handle); + } + for handle in raw_ats.into_iter() { + if &handle != &user_profile.user.handle { + reordered_ats.push(handle); + } + } 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); + let mut reordered_with_rt = Vec::new(); + for mention in reordered_ats { + if mention != rt_author_handle { + reordered_with_rt.push(mention); + } + } + reordered_with_rt.insert(1, rt_author_handle); + reordered_ats = reordered_with_rt; } - // if you're directly replying to yourself, i trust you know what you're doing and - // want to @ yourself again (this keeps self-replies from showing up on your - // profile as threaded tweets, f.ex) - if !(ats.len() > 0 && &ats[0] == &user_profile.user.handle) { - ats.remove_item(&user_profile.user.handle); - } //let ats_vec: Vec<&str> = ats.into_iter().collect(); //let full_reply = format!("{} {}", ats_vec.join(" "), reply); - let decorated_ats: Vec<String> = ats.into_iter().map(|x| format!("@{}", x)).collect(); + let decorated_ats: Vec<String> = reordered_ats.into_iter().map(|x| format!("@{}", x)).collect(); let full_reply = format!("{} {}", decorated_ats.join(" "), reply); if reply.len() > 0 { diff --git a/src/display/mod.rs b/src/display/mod.rs index 8bd233a..6115472 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -412,7 +412,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re { let to_show = display_info.log[first_tail_log..last_tail_log].iter().rev(); for line in to_show { - print!("{}{}{}/{}: {}", cursor::Goto(1, height - i), clear::CurrentLine, display_info.log.len() - 1 - i as usize, display_info.log.len() - 1, line.take(width - 7); + print!("{}{}{}/{}: {}", cursor::Goto(1, height - i), clear::CurrentLine, display_info.log.len() - 1 - i as usize, display_info.log.len() - 1, line.chars().take(width.saturating_sub(7) as usize).collect::<String>()); i = i + 1; } } diff --git a/src/main.rs b/src/main.rs index e5c3910..603108c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#![feature(vec_remove_item)] extern crate serde_json; extern crate chrono; |