From 4b74491b8b3353ae82f4dc1468e1c20546e5e03d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 6 May 2019 09:32:08 +0300 Subject: [PATCH] feed tree: set placeholder feed unread value to -1 --- classes/pref/feeds.php | 34 +++++++++++++++++----------------- js/FeedTree.js | 10 +++++----- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index fbbbdb4f4..6cbf15a58 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -66,9 +66,9 @@ class Pref_Feeds extends Handler_Protected { $cat['items'] = array(); $cat['checkbox'] = false; $cat['type'] = 'category'; - $cat['unread'] = 0; - $cat['child_unread'] = 0; - $cat['auxcounter'] = 0; + $cat['unread'] = -1; + $cat['child_unread'] = -1; + $cat['auxcounter'] = -1; $cat['parent_id'] = $cat_id; $cat['items'] = $this->get_category_items($line['id']); @@ -95,10 +95,10 @@ class Pref_Feeds extends Handler_Protected { $feed = array(); $feed['id'] = 'FEED:' . $feed_line['id']; $feed['bare_id'] = (int)$feed_line['id']; - $feed['auxcounter'] = 0; + $feed['auxcounter'] = -1; $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; - $feed['unread'] = 0; + $feed['unread'] = -1; $feed['error'] = $feed_line['last_error']; $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); $feed['param'] = make_local_datetime( @@ -153,14 +153,14 @@ class Pref_Feeds extends Handler_Protected { $item = array(); $item['id'] = 'FEED:' . $feed_id; $item['bare_id'] = (int)$feed_id; - $item['auxcounter'] = 0; + $item['auxcounter'] = -1; $item['name'] = $feed['title']; $item['checkbox'] = false; $item['error'] = ''; $item['icon'] = $feed['icon']; $item['param'] = ''; - $item['unread'] = 0; //$feed['sender']->get_unread($feed['id']); + $item['unread'] = -1; $item['type'] = 'feed'; array_push($cat['items'], $item); @@ -218,13 +218,13 @@ class Pref_Feeds extends Handler_Protected { $cat = array(); $cat['id'] = 'CAT:' . $line['id']; $cat['bare_id'] = (int)$line['id']; - $cat['auxcounter'] = 0; + $cat['auxcounter'] = -1; $cat['name'] = $line['title']; $cat['items'] = array(); $cat['checkbox'] = false; $cat['type'] = 'category'; - $cat['unread'] = 0; - $cat['child_unread'] = 0; + $cat['unread'] = -1; + $cat['child_unread'] = -1; $cat['items'] = $this->get_category_items($line['id']); @@ -242,13 +242,13 @@ class Pref_Feeds extends Handler_Protected { $cat = array(); $cat['id'] = 'CAT:0'; $cat['bare_id'] = 0; - $cat['auxcounter'] = 0; + $cat['auxcounter'] = -1; $cat['name'] = __("Uncategorized"); $cat['items'] = array(); $cat['type'] = 'category'; $cat['checkbox'] = false; - $cat['unread'] = 0; - $cat['child_unread'] = 0; + $cat['unread'] = -1; + $cat['child_unread'] = -1; $fsth = $this->pdo->prepare("SELECT id, title,last_error, ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated, update_interval @@ -263,14 +263,14 @@ class Pref_Feeds extends Handler_Protected { $feed = array(); $feed['id'] = 'FEED:' . $feed_line['id']; $feed['bare_id'] = (int)$feed_line['id']; - $feed['auxcounter'] = 0; + $feed['auxcounter'] = -1; $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); $feed['param'] = make_local_datetime( $feed_line['last_updated'], true); - $feed['unread'] = 0; + $feed['unread'] = -1; $feed['type'] = 'feed'; $feed['updates_disabled'] = (int)($feed_line['update_interval'] < 0); @@ -298,14 +298,14 @@ class Pref_Feeds extends Handler_Protected { $feed = array(); $feed['id'] = 'FEED:' . $feed_line['id']; $feed['bare_id'] = (int)$feed_line['id']; - $feed['auxcounter'] = 0; + $feed['auxcounter'] = -1; $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); $feed['param'] = make_local_datetime( $feed_line['last_updated'], true); - $feed['unread'] = 0; + $feed['unread'] = -1; $feed['type'] = 'feed'; $feed['updates_disabled'] = (int)($feed_line['update_interval'] < 0); diff --git a/js/FeedTree.js b/js/FeedTree.js index 99685a781..b43cad627 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -135,7 +135,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], args.item.unread > 0 || args.item.auxcounter > 0 ? Element.show(ctr) : Element.hide(ctr); - args.item.unread == 0 && args.item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux"); + args.item.unread <= 0 && args.item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux"); domConstruct.place(ctr, tnode.rowNode, 'first'); tnode.counterNode = ctr; @@ -171,7 +171,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], Element.show(ctr) : Element.hide(ctr); - item.unread == 0 && item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux"); + item.unread <= 0 && item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux"); } } @@ -184,7 +184,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, getLabelClass: function (item, opened) { - return (item.unread == 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread"; + return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread"; }, getRowClass: function (item, opened) { let rc = (!item.error || item.error == '') ? "dijitTreeRow" : @@ -353,7 +353,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], if (node) { const check_unread = tree.model.getFeedUnread(bare_id, true); - if (hide && cat_unread == 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) { + if (hide && cat_unread <= 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) { Effect.Fade(node[0].rowNode, {duration : 0.3, queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }}); } else { @@ -397,7 +397,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], const node = tree._itemNodesMap[id]; if (node) { - if (hide && unread == 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) { + if (hide && unread <= 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) { Effect.Fade(node[0].rowNode, {duration : 0.3, queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }}); } else {