Don't reset isRead when feed item metadata changes (#2215)

This prevents metadata changes from clearing the isRead status of feed
items as long as GUIDs remain constant. Previously, feed items with
randomized properties (like URLs generated dynamically each time the
feed is served) would be incorrectly marked as unread on every update.
This commit is contained in:
Abe Jellinek 2021-11-05 20:16:12 -07:00 committed by GitHub
parent 2cf436c67d
commit cd3304e16c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -475,9 +475,8 @@ Zotero.Feed.prototype._updateFeed = Zotero.Promise.coroutine(function* () {
if (!feedItem.hasChanged()) {
Zotero.debug("Feed item " + feedItem.guid + " has not changed");
continue
continue;
}
feedItem.isRead = false;
toSave.push(feedItem);
}
}

View file

@ -362,7 +362,7 @@ describe("Zotero.Feed", function() {
assert.isTrue(feed.lastCheck > Zotero.Date.dateToSQL(new Date(Date.now() - 1000*60), true), 'feed.lastCheck updated');
assert.isTrue(feed.lastUpdate > Zotero.Date.dateToSQL(new Date(Date.now() - 1000*60), true), 'feed.lastUpdate updated');
});
it('should update modified items and set unread', function* () {
it('should update modified items, preserving isRead', function* () {
let feedItem = yield Zotero.FeedItems.getAsyncByGUID("http://liftoff.msfc.nasa.gov/2003/06/03.html#item573");
feedItem.isRead = true;
yield feedItem.saveTx();
@ -377,7 +377,7 @@ describe("Zotero.Feed", function() {
feedItem = yield Zotero.FeedItems.getAsyncByGUID("http://liftoff.msfc.nasa.gov/2003/06/03.html#item573");
assert.notEqual(oldDateModified, feedItem.getField('date'));
assert.isFalse(feedItem.isRead)
assert.isTrue(feedItem.isRead);
});
it('should skip items that are not modified', function* () {
let save = sinon.spy(Zotero.FeedItem.prototype, 'save');
@ -400,7 +400,7 @@ describe("Zotero.Feed", function() {
feed._feedUrl = modifiedFeedUrl;
yield feed.updateFeed();
assert.equal(feed.unreadCount, 2);
assert.equal(feed.unreadCount, 1);
});
it('should add a link to enclosed pdfs from <enclosure/> elements', function* () {
let feedItem = yield Zotero.FeedItems.getAsyncByGUID("http://liftoff.msfc.nasa.gov/2003/06/03.html#item573");