Notifications: Automatically redirect to archive tab if there is no new notifs (until if user will manually go to unread tab)

This commit is contained in:
veselcraft 2022-05-26 15:25:16 +03:00
parent 5f3f3299de
commit 5b2d18e96b
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
2 changed files with 12 additions and 3 deletions

View file

@ -6,9 +6,18 @@ final class NotificationPresenter extends OpenVKPresenter
function renderFeed(): void
{
$this->assertUserLoggedIn();
$archive = $this->queryParam("act") === "archived";
$this->template->mode = $archive ? "archived" : "new";
$count = $this->user->identity->getNotificationsCount($archive);
if($count == 0 && $this->queryParam("act") == NULL) {
$mode = "archived";
$archive = true;
} else {
$mode = $archive ? "archived" : "new";
}
$this->template->mode = $mode;
$this->template->page = (int) ($this->queryParam("p") ?? 1);
$this->template->iterator = iterator_to_array($this->user->identity->getNotifications($this->template->page, $archive));
$this->template->count = $this->user->identity->getNotificationsCount($archive);

View file

@ -12,7 +12,7 @@
{block tabs}
<div n:attr="id => ($mode === 'new' ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($mode === 'new' ? 'act_tab_a' : 'ki')" href="?">{_unread}</a>
<a n:attr="id => ($mode === 'new' ? 'act_tab_a' : 'ki')" href="?act=new">{_unread}</a>
</div>
<div n:attr="id => ($mode === 'archived' ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($mode === 'archived' ? 'act_tab_a' : 'ki')" href="?act=archived">{_archive}</a>