Skip to content

Commit

Permalink
Support subscribed list (API: /:user/lists/subscriptions)
Browse files Browse the repository at this point in the history
Show list name on unified timeline's tweets.
  • Loading branch information
takuo committed Apr 6, 2010
1 parent 24c137a commit 0249f2d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
26 changes: 25 additions & 1 deletion background.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@
if(success) {
_this.listsCache = data.lists;
}
});
this.twitterBackend.subs(function(success, data, status) {
if(success) {
_this.listsCache = _this.listsCache.concat(data.lists);
}
if(callback) {
callback(success, _this.listsCache, status);
}
Expand Down Expand Up @@ -613,14 +618,33 @@
if(listId && this.listsCache) {
// Check if the listId really exists
for(var i = 0; i < this.listsCache.length; ++i) {
if(this.listsCache[i].slug == listId) {
if(this.listsCache[i].uri == listId) {
return listId;
}
}
}
return null;
},

getList: function(timelineName) {
if(!timelineName) {
timelineName = this.currentTimeline;
}
var timeline = this.timelines[timelineName];
if(!timeline) {
return null;
}
var listId = timeline.listId;
if(listId && this.listsCache) {
for(var i = 0; i < this.listsCache.length; ++i) {
if(this.listsCache[i].uri == listId) {
return this.listsCache[i];
}
}
}
return null;
},

giveMeTweets: function(timelineId, callback, syncNew, cacheOnly) {
var timeline = this.timelines[timelineId];
if(!timeline) {
Expand Down
4 changes: 3 additions & 1 deletion lib/timelines/lists_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ $.extend(ListsTweetsTimeline.prototype, MultipleTweetsTimeline.prototype, {
}

this.timelineData = listId;
this._setTimelinePath(this.manager.twitterBackend.username() + '/lists/' + this.timelineData + '/statuses');
// this._setTimelinePath(this.manager.twitterBackend.username() + '/lists/' + this.timelineData + '/statuses');
var u = listId.split("/");
timeline.setTimelinePath(u[1] + '/lists/' + u[2] + '/statuses');
this.tweetsCache = [];
this.newTweetsCache = [];
this.unreadNotified = [];
Expand Down
4 changes: 4 additions & 0 deletions lib/twitter_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ TwitterLib.prototype = {
this.ajaxRequest(this.username() + '/lists', callback, null, null, "GET");
},

subs: function(callback) {
this.ajaxRequest(this.username() + '/subscriptions', callback, null, null, "GET");
},

timeline: function(timeline_path, callback, context, params) {
this.ajaxRequest(timeline_path, callback, context, params);
},
Expand Down
9 changes: 8 additions & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,13 @@
if (geo) {
str += '<span class="geo_tag">' + geo + '</span>';
}
if (tweetTimeline.match(/^lists_/) && tweetManager.currentTimeline != tweetTimeline) {
var list = tweetManager.getList(tweetTimeline);
if (list != null) {
var path = list.uri.substr(1);
str += ' (List: <a href="#" onclick="openTab(\''+TwitterLib.URLS.BASE + path + '\');" title="@' + path + '">' + list.name + '</a>)';
}
}
str += '</div></div>';

str += '<div class="new_actions">';
Expand Down Expand Up @@ -1035,7 +1042,7 @@
$listSelect.html('');
$listSelect.append($("<option>").attr('value', _this.selector_value).text('- Select a list -'));
for(var j = 0; j < lists.length; ++j) {
$listSelect.append($("<option>").attr('value', lists[j].slug).text(lists[j].name));
$listSelect.append($("<option>").attr('value', lists[j].uri).text(lists[j].name));
}
$listSelect.append($("<option>").attr('value', _this.update_value).text('Update lists...'));
var selectedListId = tweetManager.getListId(timeline.timelineId);
Expand Down

0 comments on commit 0249f2d

Please sign in to comment.