aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-12-24 23:09:57 -0800
committerGitHub <noreply@github.com>2017-12-24 23:09:57 -0800
commit575b6858a5849547acfe43a783ef03146a373215 (patch)
treecffb070e4cef1baa71d968143bec5925cdbe92af
parent2ad6338ffb2c1cf37acd54bd8c2997d051dd02e6 (diff)
parentdd687928318cd0b4cad76228b80d1959c1319997 (diff)
Merge pull request #3 from iximeow/assorted-fixes
Assorted fixes
-rw-r--r--cache/profile.json2
-rw-r--r--src/commands/twete.rs31
-rw-r--r--src/display/mod.rs6
-rw-r--r--src/main.rs1
4 files changed, 23 insertions, 17 deletions
diff --git a/cache/profile.json b/cache/profile.json
index 8839791..32c5d68 100644
--- a/cache/profile.json
+++ b/cache/profile.json
@@ -1 +1 @@
-{"app_key":{"key":"mS0xDX2LBVOohjeHW0JsJEBhF","secret":"q54t40D7LQZgQgHScpyXan5YlTxc3qKBu8SbC7w6kH0DsBZcu9"},"profiles":{},"mutes":{"users":{},"tweets":{},"words":[]},"threads":{}}
+{"app_key":{"key":"mS0xDX2LBVOohjeHW0JsJEBhF","secret":"q54t40D7LQZgQgHScpyXan5YlTxc3qKBu8SbC7w6kH0DsBZcu9"},"curr_profile":null,"profiles":{},"mutes":{"users":{},"tweets":{},"words":[]},"threads":{}} \ No newline at end of file
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 37de481..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);
+ 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;
}
}
@@ -472,7 +472,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re
Some(DisplayMode::Reply(twid, msg)) => {
let mut lines: Vec<String> = vec![];
lines.push(std::iter::repeat("-").take((width as usize).saturating_sub(2)).collect());
- lines.extend(render_twete(&twid, tweeter, display_info, Some(width)));
+ lines.extend(render_twete(&twid, tweeter, display_info, Some(width - 2)));
let reply_delineator = "--------reply";
lines.push(format!("{}{}", reply_delineator, std::iter::repeat("-").take((width as usize).saturating_sub(reply_delineator.len() + 2)).collect::<String>()));
let msg_lines = into_display_lines(msg.split("\n").map(|x| x.to_owned()).collect(), width - 2);
@@ -561,7 +561,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re
}
};
for line in to_draw {
- print!("{}{}{}", cursor::Goto(1, height - h), clear::CurrentLine, line);
+ print!("{}{}{}", cursor::Goto(1, height - h), line, clear::UntilNewline);
h = h + 1;
if h >= height {
break;
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;