mirror of
https://github.com/openvk/openvk
synced 2024-12-23 09:01:15 +03:00
Fix video pagination
This commit is contained in:
parent
55e8412025
commit
65cd0e93df
2 changed files with 6 additions and 7 deletions
|
@ -37,13 +37,12 @@ class Videos
|
||||||
function getByUser(User $user, int $page = 1, ?int $perPage = NULL): \Traversable
|
function getByUser(User $user, int $page = 1, ?int $perPage = NULL): \Traversable
|
||||||
{
|
{
|
||||||
$perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE;
|
$perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE;
|
||||||
foreach($this->videos->where("owner", $user->getId())->page($page, $perPage) as $video)
|
foreach($this->videos->where("owner", $user->getId())->where("deleted", 0)->page($page, $perPage) as $video)
|
||||||
if(!$video->deleted)
|
|
||||||
yield new Video($video);
|
yield new Video($video);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserVideosCount(User $user): int
|
function getUserVideosCount(User $user): int
|
||||||
{
|
{
|
||||||
return sizeof($this->videos->where("owner", $user->getId()));
|
return sizeof($this->videos->where("owner", $user->getId())->where("deleted", 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,13 @@ final class VideosPresenter extends OpenVKPresenter
|
||||||
if(!$user) $this->notFound();
|
if(!$user) $this->notFound();
|
||||||
|
|
||||||
$this->template->user = $user;
|
$this->template->user = $user;
|
||||||
$this->template->videos = $this->videos->getByUser($user, $this->queryParam("p") ?? 1);
|
$this->template->videos = $this->videos->getByUser($user, (int) ($this->queryParam("p") ?? 1));
|
||||||
$this->template->count = $this->videos->getUserVideosCount($user);
|
$this->template->count = $this->videos->getUserVideosCount($user);
|
||||||
$this->template->paginatorConf = (object) [
|
$this->template->paginatorConf = (object) [
|
||||||
"count" => $this->template->count,
|
"count" => $this->template->count,
|
||||||
"page" => $this->queryParam("p") ?? 1,
|
"page" => (int) ($this->queryParam("p") ?? 1),
|
||||||
"amount" => NULL,
|
"amount" => NULL,
|
||||||
"perPage" => OPENVK_DEFAULT_PER_PAGE,
|
"perPage" => 7,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue