From d6d4e4b33e8a88cda4e5ef83b6bfff5b67b26871 Mon Sep 17 00:00:00 2001 From: Adomas Ven Date: Tue, 13 Dec 2016 16:07:43 +0200 Subject: [PATCH] Saner feed database management (#1131) * Mark feedItems read in a single batch SQL update * Automatically remove old feed items * User-facing preference globally and per-feed for feed item expiration --- chrome/content/zotero/feedSettings.js | 19 +++-- chrome/content/zotero/feedSettings.xul | 11 ++- .../preferences/preferences_advanced.xul | 16 +++- chrome/content/zotero/xpcom/data/feed.js | 73 ++++++++++--------- chrome/content/zotero/xpcom/data/feedItems.js | 24 +++--- chrome/content/zotero/xpcom/data/feeds.js | 23 ++++-- chrome/content/zotero/xpcom/schema.js | 10 ++- chrome/content/zotero/zoteroPane.js | 12 ++- chrome/locale/en-US/zotero/zotero.dtd | 6 +- defaults/preferences/zotero.js | 3 +- resource/schema/userdata.sql | 5 +- test/content/support.js | 3 +- test/tests/feedTest.js | 42 +++++++---- test/tests/feedsTest.js | 3 +- 14 files changed, 157 insertions(+), 93 deletions(-) diff --git a/chrome/content/zotero/feedSettings.js b/chrome/content/zotero/feedSettings.js index 7eedd14331..34b7576a0e 100644 --- a/chrome/content/zotero/feedSettings.js +++ b/chrome/content/zotero/feedSettings.js @@ -72,9 +72,13 @@ var Zotero_Feed_Settings = new function() { } document.getElementById('feed-ttl').value = ttl; - let cleanupAfter = data.cleanupAfter; - if (cleanupAfter === undefined) cleanupAfter = Zotero.Prefs.get('feeds.defaultCleanupAfter'); - document.getElementById('feed-cleanupAfter').value = cleanupAfter; + let cleanupReadAfter = data.cleanupReadAfter; + if (cleanupReadAfter === undefined) cleanupReadAfter = Zotero.Prefs.get('feeds.defaultCleanupReadAfter'); + document.getElementById('feed-cleanupReadAfter').value = cleanupReadAfter; + + let cleanupUnreadAfter = data.cleanupUnreadAfter; + if (cleanupUnreadAfter === undefined) cleanupUnreadAfter = Zotero.Prefs.get('feeds.defaultCleanupUnreadAfter'); + document.getElementById('feed-cleanupUnreadAfter').value = cleanupUnreadAfter; if (data.url && !data.urlIsValid) { yield this.validateURL(); @@ -93,7 +97,8 @@ var Zotero_Feed_Settings = new function() { urlIsValid = false; document.getElementById('feed-title').disabled = true; document.getElementById('feed-ttl').disabled = true; - document.getElementById('feed-cleanupAfter').disabled = true; + document.getElementById('feed-cleanupReadAfter').disabled = true; + document.getElementById('feed-cleanupUnreadAfter').disabled = true; document.documentElement.getButton('accept').disabled = true; }; @@ -130,7 +135,8 @@ var Zotero_Feed_Settings = new function() { urlIsValid = true; title.disabled = false; ttl.disabled = false; - document.getElementById('feed-cleanupAfter').disabled = false; + document.getElementById('feed-cleanupReadAfter').disabled = false; + document.getElementById('feed-cleanupUnreadAfter').disabled = false; document.documentElement.getButton('accept').disabled = false; } catch (e) { @@ -145,7 +151,8 @@ var Zotero_Feed_Settings = new function() { data.url = document.getElementById('feed-url').value; data.title = document.getElementById('feed-title').value; data.ttl = document.getElementById('feed-ttl').value * 60; - data.cleanupAfter = document.getElementById('feed-cleanupAfter').value * 1; + data.cleanupReadAfter = document.getElementById('feed-cleanupReadAfter').value * 1; + data.cleanupUnreadAfter = document.getElementById('feed-cleanupUnreadAfter').value * 1; return true; }; diff --git a/chrome/content/zotero/feedSettings.xul b/chrome/content/zotero/feedSettings.xul index 241ba3022e..451b595e56 100644 --- a/chrome/content/zotero/feedSettings.xul +++ b/chrome/content/zotero/feedSettings.xul @@ -53,9 +53,14 @@