Bug 1147113 - Filter the article properties in ReaderParent.jsm instead of ReadingList.jsm. r=adw, a=readinglist
authorJared Wein <jwein@mozilla.com>
Mon, 30 Mar 2015 12:02:52 -0400
changeset 258182 7dded32396ba
parent 258179 4e05802f6eb4
child 258183 acc50d404648
push id4617
push userdwillcoxon@mozilla.com
push date2015-04-02 02:05 +0000
treeherdermozilla-beta@818e63fbfba2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, readinglist
bugs1147113
milestone38.0
Bug 1147113 - Filter the article properties in ReaderParent.jsm instead of ReadingList.jsm. r=adw, a=readinglist
browser/components/readinglist/ReadingList.jsm
browser/modules/ReaderParent.jsm
--- a/browser/components/readinglist/ReadingList.jsm
+++ b/browser/components/readinglist/ReadingList.jsm
@@ -65,27 +65,16 @@ const ITEM_RECORD_PROPERTIES = `
   addedOn
   storedOn
   markedReadBy
   markedReadOn
   readPosition
   syncStatus
 `.trim().split(/\s+/);
 
-// Article objects that are passed to ReadingList.addItem may contain
-// some properties that are known but are not currently stored in the
-// ReadingList records. This is the list of properties that are knowingly
-// disregarded before the item is normalized.
-const ITEM_DISREGARDED_PROPERTIES = `
-  byline
-  dir
-  content
-  length
-`.trim().split(/\s+/);
-
 // Each local item has a syncStatus indicating the state of the item in relation
 // to the sync server.  See also Sync.jsm.
 const SYNC_STATUS_SYNCED = 0;
 const SYNC_STATUS_NEW = 1;
 const SYNC_STATUS_CHANGED_STATUS = 2;
 const SYNC_STATUS_CHANGED_MATERIAL = 3;
 const SYNC_STATUS_DELETED = 4;
 
@@ -1000,19 +989,16 @@ ReadingListItemIterator.prototype = {
  * aren't in ITEM_RECORD_PROPERTIES.
  *
  * @param record A non-normalized record object.
  * @return The new normalized record.
  */
 function normalizeRecord(nonNormalizedRecord) {
   let record = {};
   for (let prop in nonNormalizedRecord) {
-    if (ITEM_DISREGARDED_PROPERTIES.indexOf(prop) >= 0) {
-      continue;
-    }
     if (ITEM_RECORD_PROPERTIES.indexOf(prop) < 0) {
       throw new Error("Unrecognized item property: " + prop);
     }
     switch (prop) {
     case "url":
     case "resolvedURL":
       if (nonNormalizedRecord[prop]) {
         record[prop] = normalizeURI(nonNormalizedRecord[prop]);
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -39,17 +39,23 @@ let ReaderParent = {
     for (let msg of this.MESSAGES) {
       mm.addMessageListener(msg, this);
     }
   },
 
   receiveMessage: function(message) {
     switch (message.name) {
       case "Reader:AddToList":
-        ReadingList.addItem(message.data.article);
+        let article = message.data.article;
+        ReadingList.addItem({
+          url: article.url,
+          title: article.title,
+          excerpt: article.excerpt,
+          status: article.status
+        });
         break;
 
       case "Reader:ArticleGet":
         this._getArticle(message.data.url, message.target).then((article) => {
           // Make sure the target browser is still alive before trying to send data back.
           if (message.target.messageManager) {
             message.target.messageManager.sendAsyncMessage("Reader:ArticleData", { article: article });
           }