diff options
author | iximeow <me@iximeow.net> | 2017-10-02 02:33:05 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-10-02 02:33:05 -0700 |
commit | f272a41cf8c4a550e3a4352c478579974a5f4d91 (patch) | |
tree | ef6252e94e2bb0a2d3b7740ba42219485ce8186e /src/commands | |
parent | 8114e1ae5dcca506e1687b17c846b75a3f0257a8 (diff) |
support showing whole threads
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/mod.rs | 1 | ||||
-rw-r--r-- | src/commands/view.rs | 27 |
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); } |