diff --git a/chrome/content/zotero/xpcom/data/feed.js b/chrome/content/zotero/xpcom/data/feed.js index 7c3208235b..c591c46b08 100644 --- a/chrome/content/zotero/xpcom/data/feed.js +++ b/chrome/content/zotero/xpcom/data/feed.js @@ -331,33 +331,14 @@ Zotero.Feed.prototype.erase = Zotero.Promise.coroutine(function* (options = {}) yield Zotero.Feed._super.prototype.erase.call(this, options); }); -Zotero.Feed.prototype.getSyncedSettings = function () { - if (!this._syncedSettings) { - let syncedFeeds = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, 'feeds') || {}; - this._syncedSettings = syncedFeeds[this.url]; - } - if (!this._syncedSettings) { - this._syncedSettings = { - url: this.url, - name: this.name, - cleanupAfter: this.cleanupAfter, - refreshInterval: this.refreshInterval, - markedAsRead: {} - }; - } - return this._syncedSettings; -}; - -Zotero.Feed.prototype.setSyncedSettings = Zotero.Promise.coroutine(function* (syncedSettings, store=false) { - this._syncedSettings = syncedSettings; - if (store) { - return this.storeSyncedSettings(); - } -}); - Zotero.Feed.prototype.storeSyncedSettings = Zotero.Promise.coroutine(function* () { let syncedFeeds = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, 'feeds') || {}; - syncedFeeds[this.url] = this.getSyncedSettings(); + syncedFeeds[this.url] = { + url: this.url, + name: this.name, + cleanupAfter: this.cleanupAfter, + refreshInterval: this.refreshInterval + }; return Zotero.SyncedSettings.set(Zotero.Libraries.userLibraryID, 'feeds', syncedFeeds); }); @@ -405,7 +386,6 @@ Zotero.Feed.prototype.clearExpiredItems = Zotero.Promise.coroutine(function* (it Zotero.debug("Error clearing expired feed items"); Zotero.debug(e); } - return this.storeSyncedSettings(); }); Zotero.Feed.prototype._updateFeed = Zotero.Promise.coroutine(function* () { @@ -534,9 +514,3 @@ Zotero.Feed.prototype.updateUnreadCount = Zotero.Promise.coroutine(function* () Zotero.Notifier.trigger('unreadCountUpdated', 'feed', this.id); } }); - -Zotero.Feed.prototype.updateFromJSON = Zotero.Promise.coroutine(function* (json) { - yield this.updateFeed(); - yield Zotero.FeedItems.markAsReadByGUID(Object.keys(json.markedAsRead)); - yield this.updateUnreadCount(); -}); diff --git a/chrome/content/zotero/xpcom/data/feedItem.js b/chrome/content/zotero/xpcom/data/feedItem.js index 771c125606..79d26dd162 100644 --- a/chrome/content/zotero/xpcom/data/feedItem.js +++ b/chrome/content/zotero/xpcom/data/feedItem.js @@ -182,9 +182,6 @@ Zotero.FeedItem.prototype._saveData = Zotero.Promise.coroutine(function* (env) { Zotero.FeedItem.prototype._finalizeErase = Zotero.Promise.coroutine(function* () { // Set for syncing let feed = Zotero.Feeds.get(this.libraryID); - let syncedSettings = feed.getSyncedSettings(); - delete syncedSettings.markedAsRead[this.guid]; - yield feed.setSyncedSettings(syncedSettings); return Zotero.FeedItem._super.prototype._finalizeErase.apply(this, arguments); }); @@ -195,18 +192,9 @@ Zotero.FeedItem.prototype.toggleRead = Zotero.Promise.coroutine(function* (state if (changed) { this.isRead = state; - // Set for syncing - let feed = Zotero.Feeds.get(this.libraryID); - let syncedSettings = feed.getSyncedSettings(); - if (state) { - syncedSettings.markedAsRead[this.guid] = true; - } else { - delete syncedSettings.markedAsRead[this.guid]; - } - yield feed.setSyncedSettings(syncedSettings, true); - yield this.saveTx(); - + + let feed = Zotero.Feeds.get(this.libraryID); yield feed.updateUnreadCount(); } }); diff --git a/chrome/content/zotero/xpcom/data/feedItems.js b/chrome/content/zotero/xpcom/data/feedItems.js index 824d5e7f5e..c6ba8dbef3 100644 --- a/chrome/content/zotero/xpcom/data/feedItems.js +++ b/chrome/content/zotero/xpcom/data/feedItems.js @@ -109,7 +109,7 @@ Zotero.FeedItems = new Proxy(function() { }); /** - * Used on restore from sync + * Currently not used */ this.markAsReadByGUID = Zotero.Promise.coroutine(function* (guids) { if (! Array.isArray(guids)) { @@ -151,18 +151,9 @@ Zotero.FeedItems = new Proxy(function() { yield Zotero.DB.executeTransaction(function() { for (let i=0; i items[k].guid)); - }); }); }); diff --git a/test/tests/feedTest.js b/test/tests/feedTest.js index b3d39fb6b4..194066b8c3 100644 --- a/test/tests/feedTest.js +++ b/test/tests/feedTest.js @@ -199,39 +199,18 @@ describe("Zotero.Feed", function() { }); }); - describe("#getSyncedSettings", function() { - it("should return correct synced settings for the feed", function* () { - let url = 'http://' + Zotero.Utilities.randomString(10, 'abcde') + '.com/feed.rss'; - let syncedFeeds = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, 'feeds'); - assert.notOk(syncedFeeds[url]); - - let feed = yield createFeed({url}); - - syncedFeeds = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, 'feeds'); - assert.ok(syncedFeeds[url]); - - let syncedData = feed.getSyncedSettings(); - - assert.deepEqual(syncedData, syncedFeeds[url]); - }); - }); - describe("#storeSyncedSettings", function() { it("should store updated settings for the feed", function* () { - let guid = Zotero.Utilities.randomString(); - let feed = yield createFeed(); + let settings = { + name: Zotero.Utilities.randomString(), + url: 'http://' + Zotero.Utilities.randomString().toLowerCase() + '.com/feed.rss', + refreshInterval: 1, + cleanupAfter: 1 + }; + let feed = yield createFeed(settings); let syncedFeeds = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, 'feeds'); - assert.notOk(syncedFeeds[feed.url].markedAsRead[guid]); - - let syncedData = feed.getSyncedSettings(); - syncedData.markedAsRead[guid] = true; - yield feed.setSyncedSettings(syncedData); - yield feed.storeSyncedSettings(); - - syncedFeeds = Zotero.SyncedSettings.get(Zotero.Libraries.userLibraryID, 'feeds'); - - assert.isTrue(syncedFeeds[feed.url].markedAsRead[guid]); + assert.deepEqual(syncedFeeds[feed.url], settings); }); });