aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-02 02:33:05 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-02 02:33:05 -0700
commite6a43f3d79ded5d284c42239cca77214f177f63e (patch)
treeef6252e94e2bb0a2d3b7740ba42219485ce8186e
parentfe80b29ca03ed5e4462800804f33ecc00e1f880f (diff)
support showing whole threads
-rw-r--r--src/commands/mod.rs1
-rw-r--r--src/commands/view.rs27
-rw-r--r--src/tw/tweet.rs2
3 files changed, 28 insertions, 2 deletions
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index fc66bec..51e0e53 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -20,6 +20,7 @@ pub static COMMANDS: &[&Command] = &[
&look_up::LOOK_UP_USER,
&look_up::LOOK_UP_TWEET,
&view::VIEW,
+ &view::VIEW_THREAD,
&fav::UNFAV,
&fav::FAV,
&twete::DEL,
diff --git a/src/commands/view.rs b/src/commands/view.rs
index d01ff1b..cc098e7 100644
--- a/src/commands/view.rs
+++ b/src/commands/view.rs
@@ -18,5 +18,30 @@ fn view(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {
let inner_twid = u64::from_str(&line).unwrap();
let twete = tweeter.tweet_by_innerid(inner_twid).unwrap();
display::render_twete(&twete.id, tweeter);
- println!("link: https://twitter.com/i/web/status/{}", twete.id);
+ println!(" link: https://twitter.com/i/web/status/{}", twete.id);
+}
+
+pub static VIEW_THREAD: Command = Command {
+ keyword: "view_tr",
+ params: 1,
+ exec: view_tr
+};
+
+fn view_tr(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+ // TODO handle this unwrap
+ let inner_twid = u64::from_str(&line).unwrap();
+ view_tr_inner(inner_twid, tweeter, queryer);
+}
+
+fn view_tr_inner(id: u64, mut tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+ let twete: tw::tweet::Tweet = tweeter.tweet_by_innerid(id).unwrap().to_owned();
+ if let Some(reply_id) = twete.reply_to_tweet.clone() {
+ if let Some(reply_internal_id) = tweeter.fetch_tweet(&reply_id, queryer).map(|x| x.internal_id).map(|x| x.to_owned()) {
+ view_tr_inner(reply_internal_id, tweeter, queryer);
+ println!(" |");
+ println!(" v");
+ }
+ }
+ display::render_twete(&twete.id, tweeter);
+// println!("link: https://twitter.com/i/web/status/{}", twete.id);
}
diff --git a/src/tw/tweet.rs b/src/tw/tweet.rs
index aa272d6..72802ca 100644
--- a/src/tw/tweet.rs
+++ b/src/tw/tweet.rs
@@ -2,7 +2,7 @@ extern crate serde_json;
use tw::user::User;
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Tweet {
pub id: String,
pub author_id: String,