Fix keep state after favourites tags (#4178)

* Fix keep state after favourites tags
#fix https://github.com/FreshRSS/FreshRSS/issues/4124 regression

* Optimisation
This commit is contained in:
Alexandre Alapetite
2022-01-29 14:19:16 +01:00
committed by GitHub
parent 2e805f8c0b
commit 8808fb4545
3 changed files with 28 additions and 20 deletions

View File

@@ -196,11 +196,14 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
'state', FreshRSS_Context::$user_conf->default_state
);
$state_forced_by_user = Minz_Request::param('state', false) !== false;
if (FreshRSS_Context::$user_conf->default_view === 'adaptive' &&
FreshRSS_Context::$get_unread <= 0 &&
!FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) &&
!$state_forced_by_user) {
FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
if (!$state_forced_by_user && !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) {
if (FreshRSS_Context::$user_conf->default_view === 'adaptive' && FreshRSS_Context::$get_unread <= 0) {
FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
}
if (FreshRSS_Context::$user_conf->show_fav_unread &&
(FreshRSS_Context::isCurrentGet('s') || FreshRSS_Context::isCurrentGet('T') || FreshRSS_Context::isTag())) {
FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
}
}
FreshRSS_Context::$search = new FreshRSS_BooleanSearch(Minz_Request::param('search', ''));

View File

@@ -195,16 +195,23 @@ class FreshRSS_Context {
}
/**
* Return true if the current request targets a feed (and not a category or all articles), false otherwise.
* @return bool true if the current request targets a feed (and not a category or all articles), false otherwise.
*/
public static function isFeed() {
public static function isFeed(): bool {
return self::$current_get['feed'] != false;
}
/**
* Return true if $get parameter correspond to the $current_get attribute.
* @return bool true if the current request targets a tag (though not all tags), false otherwise.
*/
public static function isCurrentGet($get) {
public static function isTag(): bool {
return self::$current_get['tag'] != false;
}
/**
* @return bool true if $get parameter correspond to the $current_get attribute.
*/
public static function isCurrentGet($get): bool {
$type = $get[0];
$id = substr($get, 2);

View File

@@ -8,11 +8,9 @@
$class = ' state_unread';
}
$state_filter_fav = FreshRSS_Context::$user_conf->show_fav_unread ? '&state=3' : '';
$state_filter_cat = Minz_Request::param('state', '');
if ($state_filter_cat) {
$state_filter_cat = '&state=' . $state_filter_cat;
$state_filter_manual = Minz_Request::param('state', '');
if ($state_filter_manual != '') {
$state_filter_manual = '&state=' . $state_filter_manual;
}
?>
<nav class="nav aside aside_feed<?= $class ?>" id="aside_feed">
@@ -33,14 +31,14 @@
<li class="tree-folder category all<?= FreshRSS_Context::isCurrentGet('a') ? ' active' : '' ?>">
<div class="tree-folder-title">
<?= _i('all') ?> <a class="title" data-unread="<?= format_number(FreshRSS_Context::$total_unread) ?>" href="<?=
_url('index', $actual_view) . $state_filter_cat ?>"><?= _t('index.menu.main_stream') ?></a>
_url('index', $actual_view) . $state_filter_manual ?>"><?= _t('index.menu.main_stream') ?></a>
</div>
</li>
<li class="tree-folder category favorites<?= FreshRSS_Context::isCurrentGet('s') ? ' active' : '' ?>">
<div class="tree-folder-title">
<?= _i('bookmark') ?>
<a class="title" data-unread="<?= format_number(FreshRSS_Context::$total_starred['unread']) ?>" href="<?= _url('index', $actual_view, 'get', 's') . $state_filter_fav ?>">
<a class="title" data-unread="<?= format_number(FreshRSS_Context::$total_starred['unread']) ?>" href="<?= _url('index', $actual_view, 'get', 's') . $state_filter_manual ?>">
<?= _t('index.menu.favorites', format_number(FreshRSS_Context::$total_starred['all'])) ?>
</a>
</div>
@@ -53,7 +51,7 @@
<li id="tags" class="tree-folder category tags<?= $t_active ? ' active' : '' ?>" data-unread="<?= format_number($this->nbUnreadTags) ?>">
<div class="tree-folder-title">
<a class="dropdown-toggle" href="#"><?= _i($t_show ? 'up' : 'down') ?></a>
<a class="title" data-unread="<?= format_number($this->nbUnreadTags) ?>" href="<?= _url('index', $actual_view, 'get', 'T') . $state_filter_fav ?>"><?= _t('index.menu.tags') ?></a>
<a class="title" data-unread="<?= format_number($this->nbUnreadTags) ?>" href="<?= _url('index', $actual_view, 'get', 'T') . $state_filter_manual ?>"><?= _t('index.menu.tags') ?></a>
</div>
<ul class="tree-folder-items<?= $t_show ? ' active' : '' ?>">
<?php
@@ -66,7 +64,7 @@
<?php /* tag_config_template */ ?>
</div>
<?= FreshRSS_Themes::alt('label') ?> <a class="item-title" data-unread="<?= format_number($tag->nbUnread()) ?>" href="<?=
_url('index', $actual_view, 'get', 't_' . $tag->id()) . $state_filter_fav ?>"><?= $tag->name() ?></a>
_url('index', $actual_view, 'get', 't_' . $tag->id()) . $state_filter_manual ?>"><?= $tag->name() ?></a>
</li>
<?php endforeach; ?>
</ul>
@@ -86,7 +84,7 @@
<div class="tree-folder-title">
<a class="dropdown-toggle" href="#"><?= _i($c_show ? 'up' : 'down') ?></a>
<a class="title<?= $cat->hasFeedsWithError() ? ' error' : '' ?>" data-unread="<?=
format_number($cat->nbNotRead()) ?>" href="<?= _url('index', $actual_view, 'get', 'c_' . $cat->id()) . $state_filter_cat?>"><?= $cat->name() ?></a>
format_number($cat->nbNotRead()) ?>" href="<?= _url('index', $actual_view, 'get', 'c_' . $cat->id()) . $state_filter_manual ?>"><?= $cat->name() ?></a>
</div>
<ul class="tree-folder-items<?= $c_show ? ' active' : '' ?>">
@@ -104,7 +102,7 @@
</div>
<?php if (FreshRSS_Context::$user_conf->show_favicons): ?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php endif; ?>
<a class="item-title" data-unread="<?= format_number($feed->nbNotRead()) ?>" href="<?=
_url('index', $actual_view, 'get', 'f_' . $feed->id()). $state_filter_cat?>"><?= $feed->name() ?></a>
_url('index', $actual_view, 'get', 'f_' . $feed->id()). $state_filter_manual ?>"><?= $feed->name() ?></a>
</li>
<?php } ?>
</ul>