aboutsummaryrefslogtreecommitdiff
path: root/src/commands/twete.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/twete.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/twete.rs')
-rw-r--r--src/commands/twete.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/commands/twete.rs b/src/commands/twete.rs
index c399df1..9f5cb0d 100644
--- a/src/commands/twete.rs
+++ b/src/commands/twete.rs
@@ -56,7 +56,7 @@ fn thread(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
let id_str = text.trim();
if reply.len() > 0 {
if let Some(inner_twid) = u64::from_str(&id_str).ok() {
- if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(inner_twid)) {
+ if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(inner_twid)).map(|x| x.clone()) {
let handle = &tweeter.retrieve_user(&twete.author_id).unwrap().handle;
// TODO: definitely breaks if you change your handle right now
if handle == &tweeter.current_user.handle {
@@ -92,7 +92,8 @@ fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
let id_str = text.trim();
if reply.len() > 0 {
if let Some(inner_twid) = u64::from_str(&id_str).ok() {
- if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(inner_twid)) {
+ // TODO: probably should just have Tweet impl Copy or something
+ if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(inner_twid)).map(|x| x.clone()) {
// 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();
@@ -103,13 +104,12 @@ fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
*/
ats.remove_item(&author_handle);
ats.insert(0, author_handle);
- // no idea why i have to .to_owned() here --v-- what about twete.rt_tweet is a move?
- if let Some(rt_tweet) = twete.rt_tweet.to_owned().and_then(|id| tweeter.retrieve_tweet(&TweetId::Twitter(id))) {
+ 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);
}
- if let Some(qt_tweet) = twete.quoted_tweet_id.to_owned().and_then(|id| tweeter.retrieve_tweet(&TweetId::Twitter(id))) {
+ if let Some(qt_tweet) = twete.quoted_tweet_id.and_then(|id| tweeter.retrieve_tweet(&TweetId::Twitter(id))).map(|x| x.clone()) {
// let qt_author_handle = tweeter.retrieve_user(&qt_tweet.author_id).unwrap().handle.to_owned();
// ats.remove_item(&qt_author_handle);
// ats.insert(1, qt_author_handle);
@@ -145,7 +145,7 @@ fn quote(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
let id_str = text.trim();
if reply.len() > 0 {
if let Some(inner_twid) = u64::from_str(&id_str).ok() {
- if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(inner_twid)) {
+ if let Some(twete) = tweeter.retrieve_tweet(&TweetId::Bare(inner_twid)).map(|x| x.clone()) {
let substituted = ::url_encode(reply);
let attachment_url = ::url_encode(
&format!(