Permalink
Browse files

fallback for dynamic "in reply to" load failure is going to the actua…

…l page
  • Loading branch information...
1 parent 201c973 commit fa1f2a7b32cfc5434c98db77e177a98e4ee4c1f5 @mislav committed Jun 7, 2009
Showing with 6 additions and 3 deletions.
  1. +6 −3 endless_tweets/endless_tweets.js
@@ -202,9 +202,12 @@ if (content) {
var link = up(e.target, 'a', this)
if (link && /^\s*in reply to /.test(link.textContent)) {
var statusID = link.href.match(/(\d+)$/)[1],
- statusUrl = '/statuses/show/' + statusID + '.json'
+ statusUrl = '/statuses/show/' + statusID + '.json',
+ fallback = function(xhr) { window.location = link.href }
+
twttr.loading()
- loadJSON(statusUrl, function(response) {
+ loadJSON(statusUrl, function(response, xhr) {
+ if (xhr.status >= 400) { fallback(xhr); return }
onAvatarLoad(response, function() {
var update = buildUpdateFromJSON(response),
currentStatus = up(link, '.status', content)
@@ -221,7 +224,7 @@ if (content) {
livequeryRun()
$et.trackPageview(statusUrl)
})
- })
+ }, { onerror: fallback })
e.preventDefault()
}
}, false)

0 comments on commit fa1f2a7

Please sign in to comment.