aboutsummaryrefslogtreecommitdiff
path: root/src/commands/thread.rs
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-23 01:19:20 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-23 01:19:20 -0700
commitaaed866268616b145026dea6e40b5ab5d57c79c0 (patch)
tree2d86c2251adb63778123f960487745d9eb4efbdf /src/commands/thread.rs
parentb9547026cb70ac407aaae79920f623bd66c57c34 (diff)
thingiemapoo grows a real display!
kind of. add DisplayInfo struct that eventually can be used for rendering to any particular interface. I care primarily about rendering to a CLI, so. to support this: many instances of rendering with println!() are moved to at least be orchestrated by display::paint, which will eventually become smart enough to handle a reserved area for state notifications from the client, and buffer input nicely, .... more code moved over to use TweetId instead of bare strings because DisplayInfo is currently a member on TwitterCache, any cases of writing to DisplayInfo also involve writing to TwitterCache, which means TwitterCache is mut like... everywhere. Also, invalid TweetId in IdConversions ends up logging, meaning anything calling that conversion requires a mut TwitterCache, by the above paragraph.
Diffstat (limited to 'src/commands/thread.rs')
-rw-r--r--src/commands/thread.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/commands/thread.rs b/src/commands/thread.rs
index 57b410c..fd491ba 100644
--- a/src/commands/thread.rs
+++ b/src/commands/thread.rs
@@ -6,8 +6,6 @@ use tw::TweetId;
use commands::Command;
-use std::str::FromStr;
-
pub static FORGET_THREAD: Command = Command {
keyword: "forget",
params: 1,
@@ -34,13 +32,13 @@ fn remember(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer
if name.len() > 0 {
let maybe_id = TweetId::parse(line.to_owned());
match maybe_id {
- Some(twid) => {
+ Ok(twid) => {
let twete = tweeter.retrieve_tweet(&twid).unwrap().clone();
tweeter.set_thread(name.to_string(), twete.internal_id);
println!("Ok! Recorded {:?} as thread {}", twid, name);
}
- None => {
- println!("Invalid id: {}", line);
+ Err(e) => {
+ println!("Invalid id: {}", e);
}
}
}
@@ -55,12 +53,16 @@ pub static LIST_THREADS: Command = Command {
fn ls_threads(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
println!("Threads: ");
- for k in tweeter.threads() {
+ let threads: Vec<String> = tweeter.threads().collect::<Vec<&String>>().into_iter().map(|x| x.to_owned()).collect::<Vec<String>>();
+ for k in threads {
println!("Thread: {}", k);
- let latest_inner_id = tweeter.latest_in_thread(k.to_owned()).unwrap();
- if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(*latest_inner_id)) {
+ let latest_inner_id = tweeter.latest_in_thread(k.to_owned()).unwrap().to_owned();
+ // should be able to just directly render TweetId.. and threads should be Vec<TweetId>...
+ let twete_id_TEMP = tweeter.retrieve_tweet(&TweetId::Bare(latest_inner_id)).map(|x| x.id.to_owned());
+ if let Some(twete) = twete_id_TEMP {
// gross..
- display::render_twete(&twete.id, tweeter);
+ // and this ought to be a command to tweeter.display_info anyway...
+ display::render_twete(&TweetId::Twitter(twete), tweeter);
println!("");
} else {
println!("ERROR no tweet for remembered thread.");