Add pagination for notifications
And correctly close an <a> tag
This commit is contained in:
@@ -54,6 +54,7 @@ fn main() {
|
||||
routes::likes::create,
|
||||
routes::likes::create_auth,
|
||||
|
||||
routes::notifications::paginated_notifications,
|
||||
routes::notifications::notifications,
|
||||
routes::notifications::notifications_auth,
|
||||
|
||||
|
||||
@@ -3,13 +3,21 @@ use rocket_contrib::Template;
|
||||
|
||||
use plume_common::utils;
|
||||
use plume_models::{db_conn::DbConn, notifications::Notification, users::User};
|
||||
use routes::Page;
|
||||
|
||||
#[get("/notifications?<page>")]
|
||||
fn paginated_notifications(conn: DbConn, user: User, page: Page) -> Template {
|
||||
Template::render("notifications/index", json!({
|
||||
"account": user,
|
||||
"notifications": Notification::page_for_user(&*conn, &user, page.limits()),
|
||||
"page": page.page,
|
||||
"n_pages": Page::total(Notification::find_for_user(&*conn, &user).len() as i32)
|
||||
}))
|
||||
}
|
||||
|
||||
#[get("/notifications")]
|
||||
fn notifications(conn: DbConn, user: User) -> Template {
|
||||
Template::render("notifications/index", json!({
|
||||
"account": user,
|
||||
"notifications": Notification::find_for_user(&*conn, &user)
|
||||
}))
|
||||
paginated_notifications(conn, user, Page::first())
|
||||
}
|
||||
|
||||
#[get("/notifications", rank = 2)]
|
||||
|
||||
Reference in New Issue
Block a user