Cleanup thread->by_page

This commit is contained in:
swagg boi 2023-05-29 00:35:33 -04:00
parent e8d3e716ce
commit 957885a38e
2 changed files with 10 additions and 19 deletions

View file

@ -76,24 +76,15 @@ sub by_page($self) {
my $last_page = $self->thread->last_page;
my $threads = $self->thread->by_page($this_page);
if (my $first_thread = $threads->[0]) {
$self->stash(
threads => $threads,
this_page => $this_page,
last_page => $last_page,
base_path => $base_path
)
}
else {
$self->stash(
threads => [],
this_page => undef,
last_page => undef,
base_path => undef,
status => 404,
error => 'Page not found 🕵️'
)
}
$self->stash(
threads => $threads,
this_page => $this_page,
last_page => $last_page,
base_path => $base_path
);
$self->stash(status => 404, error => 'Page not found 🕵️')
unless scalar @{$threads};
$self->render;
}

View file

@ -1,7 +1,7 @@
% layout 'default';
% title 'Threads List';
<h2 class="page-title"><%= title %></h2>
<% if (my $first_thread = $threads->[0]) { =%>
<% if (scalar @{$threads}) { =%>
<main class="pager">
<% for my $thread (@{$threads}) { =%>
<article class="post">