diff options
| author | 2021-09-19 10:56:38 +0200 | |
|---|---|---|
| committer | 2021-09-19 10:56:38 +0200 | |
| commit | a7aca6c0abfd905669004c1e4f7c8328060df27e (patch) | |
| tree | 3edd507ce9ce0762f0faf3c24108f3b1d24988e7 /app/Models/Feed.php | |
| parent | dfc89831d4e363f62dea9df71c6b4af21cc7d7c7 (diff) | |
Improved feed action filters (#3303)
* Re-order some feed options
* Option to auto mark as read existing titles
* Option to keep at max n unread articles per feed
Diffstat (limited to 'app/Models/Feed.php')
| -rw-r--r-- | app/Models/Feed.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 012bdced8..423b913b0 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -15,6 +15,7 @@ class FreshRSS_Feed extends Minz_Model { private $category = 1; private $nbEntries = -1; private $nbNotRead = -1; + private $nbPendingNotRead = 0; private $name = ''; private $website = ''; private $description = ''; @@ -141,13 +142,13 @@ class FreshRSS_Feed extends Minz_Model { return $this->nbEntries; } - public function nbNotRead() { + public function nbNotRead($includePending = false) { if ($this->nbNotRead < 0) { $feedDAO = FreshRSS_Factory::createFeedDao(); $this->nbNotRead = $feedDAO->countNotRead($this->id()); } - return $this->nbNotRead; + return $this->nbNotRead + ($includePending ? $this->nbPendingNotRead : 0); } public function faviconPrepare() { require_once(LIB_PATH . '/favicons.php'); @@ -475,6 +476,24 @@ class FreshRSS_Feed extends Minz_Model { } } + /** + * To keep track of some new potentially unread articles since last commit+fetch from database + */ + public function incPendingUnread($n = 1) { + $this->nbPendingNotRead += $n; + } + + public function keepMaxUnread() { + $keepMaxUnread = $this->attributes('keep_max_n_unread'); + if ($keepMaxUnread == false) { + $keepMaxUnread = FreshRSS_Context::$user_conf->mark_when['max_n_unread']; + } + if ($keepMaxUnread > 0 && $this->nbNotRead(false) + $this->nbPendingNotRead > $keepMaxUnread) { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $feedDAO->keepMaxUnread($this->id(), max(0, $keepMaxUnread - $this->nbPendingNotRead)); + } + } + public function cleanOldEntries() { //Remember to call updateCachedValue($id_feed) or updateCachedValues() just after $archiving = $this->attributes('archiving'); if ($archiving == null) { |
