2020-06-07 19:04:43 +03:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
namespace openvk\Web\Presenters;
|
|
|
|
|
|
|
|
final class NotificationPresenter extends OpenVKPresenter
|
|
|
|
{
|
2022-09-17 00:19:46 +03:00
|
|
|
protected $presenterName = "notification";
|
|
|
|
|
2020-06-07 19:04:43 +03:00
|
|
|
function renderFeed(): void
|
|
|
|
{
|
|
|
|
$this->assertUserLoggedIn();
|
2022-05-26 15:25:16 +03:00
|
|
|
|
2020-06-07 19:04:43 +03:00
|
|
|
$archive = $this->queryParam("act") === "archived";
|
2022-05-26 15:26:38 +03:00
|
|
|
$count = $this->user->identity->getNotificationsCount($archive);
|
2022-05-26 15:25:16 +03:00
|
|
|
|
|
|
|
if($count == 0 && $this->queryParam("act") == NULL) {
|
|
|
|
$mode = "archived";
|
|
|
|
$archive = true;
|
|
|
|
} else {
|
|
|
|
$mode = $archive ? "archived" : "new";
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->template->mode = $mode;
|
2020-06-07 19:04:43 +03:00
|
|
|
$this->template->page = (int) ($this->queryParam("p") ?? 1);
|
|
|
|
$this->template->iterator = iterator_to_array($this->user->identity->getNotifications($this->template->page, $archive));
|
2022-05-26 15:26:38 +03:00
|
|
|
$this->template->count = $count;
|
2020-06-07 19:04:43 +03:00
|
|
|
|
|
|
|
$this->user->identity->updateNotificationOffset();
|
|
|
|
$this->user->identity->save();
|
|
|
|
}
|
|
|
|
}
|