aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/mod.rs1
-rw-r--r--src/commands/view.rs27
2 files changed, 27 insertions, 1 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);
}