mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Do not omit zero-unread items in TTRSS getCounter operation
Though TTRSS itself (usually) omits items that have a counter of zero, at least one client takes this to mean the last-seen counter is unchanged, rather than zero.
This commit is contained in:
parent
adece521a9
commit
af42bceac0
2 changed files with 10 additions and 18 deletions
|
@ -140,6 +140,7 @@ We are not aware of any other extensions to the TTRSS protocol. If you know of a
|
||||||
- Article hashes are normally SHA1; The Arsse uses SHA256 hashes
|
- Article hashes are normally SHA1; The Arsse uses SHA256 hashes
|
||||||
- Article attachments normally have unique IDs; The Arsse always gives attachments an ID of `"0"`
|
- Article attachments normally have unique IDs; The Arsse always gives attachments an ID of `"0"`
|
||||||
- The default sort order of the `getHeadlines` operation normally uses custom sorting for "special" feeds; The Arsse's default sort order is equivalent to `feed_dates` for all feeds
|
- The default sort order of the `getHeadlines` operation normally uses custom sorting for "special" feeds; The Arsse's default sort order is equivalent to `feed_dates` for all feeds
|
||||||
|
- The `getCounters` operation normally omits members with zero unread; The Arsse includes everything to appease some clients
|
||||||
|
|
||||||
#### Errors and ambiguities
|
#### Errors and ambiguities
|
||||||
|
|
||||||
|
|
|
@ -230,14 +230,12 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
$categories[] = ['id' => self::CAT_LABELS, 'name' => Arsse::$lang->msg("API.TTRSS.Category.Labels"), 'parent' => 0, 'children' => 0, 'counter' => 0];
|
$categories[] = ['id' => self::CAT_LABELS, 'name' => Arsse::$lang->msg("API.TTRSS.Category.Labels"), 'parent' => 0, 'children' => 0, 'counter' => 0];
|
||||||
// prepare data for each subscription; we also add unread counts for their host categories
|
// prepare data for each subscription; we also add unread counts for their host categories
|
||||||
foreach (Arsse::$db->subscriptionList($user) as $f) {
|
foreach (Arsse::$db->subscriptionList($user) as $f) {
|
||||||
if ($f['unread']) {
|
|
||||||
// add the feed to the list of feeds
|
// add the feed to the list of feeds
|
||||||
$feeds[] = ['id' => (string) $f['id'], 'updated' => Date::transform($f['updated'], "iso8601", "sql"),'counter' => $f['unread'], 'has_img' => (int) (strlen((string) $f['favicon']) > 0)]; // ID is cast to string for consistency with TTRSS
|
$feeds[] = ['id' => (string) $f['id'], 'updated' => Date::transform($f['updated'], "iso8601", "sql"),'counter' => $f['unread'], 'has_img' => (int) (strlen((string) $f['favicon']) > 0)]; // ID is cast to string for consistency with TTRSS
|
||||||
// add the feed's unread count to the global unread count
|
// add the feed's unread count to the global unread count
|
||||||
$countAll += $f['unread'];
|
$countAll += $f['unread'];
|
||||||
// add the feed's unread count to its category unread count
|
// add the feed's unread count to its category unread count
|
||||||
$categories[$catmap[(int) $f['folder']]]['counter'] += $f['unread'];
|
$categories[$catmap[(int) $f['folder']]]['counter'] += $f['unread'];
|
||||||
}
|
|
||||||
// increment the global feed count
|
// increment the global feed count
|
||||||
$countSubs += 1;
|
$countSubs += 1;
|
||||||
}
|
}
|
||||||
|
@ -247,9 +245,8 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
$labels[] = ['id' => $this->labelOut($l['id']), 'counter' => $unread, 'auxcounter' => $l['articles']];
|
$labels[] = ['id' => $this->labelOut($l['id']), 'counter' => $unread, 'auxcounter' => $l['articles']];
|
||||||
$categories[$catmap[self::CAT_LABELS]]['counter'] += $unread;
|
$categories[$catmap[self::CAT_LABELS]]['counter'] += $unread;
|
||||||
}
|
}
|
||||||
// do a second pass on categories, summing descendant unread counts for ancestors
|
// do a second pass on categories, summing descendant unread counts for ancestors and building a final list
|
||||||
$cats = $categories;
|
$cats = $categories;
|
||||||
$catCounts = [];
|
|
||||||
while ($cats) {
|
while ($cats) {
|
||||||
foreach ($cats as $c) {
|
foreach ($cats as $c) {
|
||||||
if ($c['children']) {
|
if ($c['children']) {
|
||||||
|
@ -261,18 +258,12 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
$cats[$catmap[$c['parent']]]['counter'] += $c['counter'];
|
$cats[$catmap[$c['parent']]]['counter'] += $c['counter'];
|
||||||
$cats[$catmap[$c['parent']]]['children'] -= 1;
|
$cats[$catmap[$c['parent']]]['children'] -= 1;
|
||||||
}
|
}
|
||||||
$catCounts[$c['id']] = $c['counter'];
|
// output the category
|
||||||
|
$cats[] = ['id' => $c['id'], 'kind' => "cat", 'counter' => $c['counter']];
|
||||||
// remove the category from the input list
|
// remove the category from the input list
|
||||||
unset($cats[$catmap[$c['id']]]);
|
unset($cats[$catmap[$c['id']]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do a third pass on categories, building a final category list
|
|
||||||
foreach ($categories as $c) {
|
|
||||||
// only include categories with unread articles
|
|
||||||
if ($catCounts[$c['id']]) {
|
|
||||||
$cats[] = ['id' => $c['id'], 'kind' => "cat", 'counter' => $catCounts[$c['id']]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// prepare data for the virtual feeds and other counters
|
// prepare data for the virtual feeds and other counters
|
||||||
$special = [
|
$special = [
|
||||||
['id' => "global-unread", 'counter' => $countAll], //this should not count archived articles, but we do not have an archive
|
['id' => "global-unread", 'counter' => $countAll], //this should not count archived articles, but we do not have an archive
|
||||||
|
|
Loading…
Reference in a new issue