Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2008-09-24 15:11:53 (GMT)
committer dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2008-09-24 15:11:53 (GMT)
commit6a116e93fe607ffedcbb71aa81771e7bb751c691 (patch)
treecd3926005803d347ba7366ef69dbc850aa13bd3a
parent7adbfdf26ff72dfa99ca2b8d03e2767b421cb557 (diff)
Added feed item sorting.
git-svn-id: http://svn.mozilla.org/addons/trunk@18553 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r--bandwagon/content/scripts/factory/feedFactory.js3
-rw-r--r--bandwagon/content/scripts/model/feed.js22
-rw-r--r--bandwagon/content/ui/feedsPaneController.js11
3 files changed, 30 insertions, 6 deletions
diff --git a/bandwagon/content/scripts/factory/feedFactory.js b/bandwagon/content/scripts/factory/feedFactory.js
index 802fd1a..d6835d7 100644
--- a/bandwagon/content/scripts/factory/feedFactory.js
+++ b/bandwagon/content/scripts/factory/feedFactory.js
@@ -210,11 +210,12 @@ Bandwagon.Factory.FeedFactory.prototype._openFeedItems = function(feed)
{
var feedItems = {};
- var statement = this.connection.createStatement("SELECT addons.*, feedItems.id, feedItems.read FROM addons LEFT JOIN feedItems ON addons.id = feedItems.addon WHERE feedItems.feed = ?1");
+ var statement = this.connection.createStatement("SELECT addons.*, feedItems.id, feedItems.read FROM addons LEFT JOIN feedItems ON addons.id = feedItems.addon WHERE feedItems.feed = ?1 LIMIT ?2");
try
{
statement.bindInt32Parameter(0, feed.id);
+ statement.bindInt32Parameter(1, this.Bandwagon.DEFAULT_FEED_ITEMS_PER_PAGE);
while (statement.executeStep())
{
diff --git a/bandwagon/content/scripts/model/feed.js b/bandwagon/content/scripts/model/feed.js
index 265dbfa..ddd440d 100644
--- a/bandwagon/content/scripts/model/feed.js
+++ b/bandwagon/content/scripts/model/feed.js
@@ -104,6 +104,28 @@ Bandwagon.Model.Feed.prototype.setAllNotified = function()
}
}
+Bandwagon.Model.Feed.prototype.getSortedFeedItems = function()
+{
+ var sortedFeedItems = [];
+
+ for (var id in this.feedItems)
+ {
+ sortedFeedItems.push(this.feedItems[id]);
+ }
+
+ sortedFeedItems.sort(function(a, b)
+ {
+ // sorting is unread, then dateadded
+
+ if (a.read == false && b.read == true ) return -1;
+ if (a.read == true && b.read == false ) return 1;
+
+ return (a.dateAdded.getTime() < b.dateAdded.getTime()?1:-1);
+ });
+
+ return sortedFeedItems;
+}
+
Bandwagon.Model.Feed.prototype.toString = function()
{
return this.name + " (" + this.url + ")";
diff --git a/bandwagon/content/ui/feedsPaneController.js b/bandwagon/content/ui/feedsPaneController.js
index 8682d9c..474b782 100644
--- a/bandwagon/content/ui/feedsPaneController.js
+++ b/bandwagon/content/ui/feedsPaneController.js
@@ -581,16 +581,17 @@ Bandwagon.Controller.FeedsPane._repopulateFeedItemsList = function(feed)
Bandwagon.Logger.debug("Bandwagon.Controller.FeedsPane: repopulating feed '" + feed.url + "'");
+ // sort by feedItem.dateAdded
+
+ var feedItemsSorted = feed.getSortedFeedItems();
+
// repopulate with feed items
var feedItemsPerPage = bandwagonService.getFeedItemsPerPage(feed);
- for (var id in feed.feedItems)
+ for (var i=0; (i<feedItemsSorted.length&&i<feedItemsPerPage); i++)
{
- if (feedItemsPerPage-- == 0)
- break;
-
- var feedItem = feed.feedItems[id];
+ var feedItem = feed.feedItems[feedItemsSorted[i].guid];
if (feedItem == null)
continue;