February 29, 2012 at 11:07 PM by Dr. Drang
OK, I realize that posts about Dr. Twoot aren’t especially useful or interesting to anyone other than me, but I need to finish off what I started two nights ago: a TiVo-like system for viewing my Twitter stream with a time delay.
My motivation is straightforward. I often record live TV shows like the Oscars or the Super Bowl and start watching them an hour or so later while the show is still recording. I fast forward through the commercials and boring parts and, if I’ve timed it right, reach the end of the recording at about the same time as the live show ends. Reading Twitter comments on the show is fun, but I don’t want to see tweets about things that are further along in the show than I am.
Enter the tweet delayer, a new feature in Dr. Twoot that filters out tweets that are more recent than a user-settable delay.
The user interface is kind of dull and ugly right now, but I wanted to get the delay working before I worried too much about how it looked.
Here’s how it works. When I launch Dr. Twoot, the delay is off. It grabs the 50 most recent tweets in my
home_timeline and any
mentions that came up within that span. The tweets are formatted and added to the window, but the more recent of them aren’t immediately visible because I haven’t scrolled to them. If I want to avoid seeing tweets that were, for example, sent in the last 60 minutes, I enter 60 in the delay field and refresh (⌘R). Dr. Twoot uses
localStorage to keep track of the delay value across the refresh and redisplays the tweets, this time filtering out the ones posted in the last hour.
Every five minutes, Dr. Twoot updates to add tweets to the display, but these “new” tweets are always an hour old. So now I can watch the event via TiVo and read tweets about it without seeing spoilers.
And as I fast forward in TiVo to get closer to real time, I can adjust the delay value in Dr. Twoot to match. This time I don’t need to refresh—Dr. Twoot uses the new delay at the next update.
Even though it seems to be working, I’m sure the code that implements the
localStorage is wrong in one or more ways; this is the first time I’ve used it, and I just jumped in. I’ve read enough about
localStorage to recognize it’s usefulness, but I don’t really know its ins and outs yet. For example, I don’t understand why I can’t get the stored delay value when I first launch Dr. Twoot. Some experimentation and documentation review are in order (I promise to spare you the details of my iterative learning process).