From a87016a23f95455ceaff5249d5ff26279cb5f6c7 Mon Sep 17 00:00:00 2001 From: Sli Date: Thu, 20 Feb 2025 18:13:40 +0100 Subject: [PATCH] Apply some review comments --- sas/static/bundled/sas/album-index.ts | 8 +++++- sas/templates/sas/album.jinja | 4 +-- sas/templates/sas/download_pictures.jinja | 30 ----------------------- sas/templates/sas/macros.jinja | 30 ++++++++++++++++++++++- sas/templates/sas/user_pictures.jinja | 2 +- 5 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 sas/templates/sas/download_pictures.jinja diff --git a/sas/static/bundled/sas/album-index.ts b/sas/static/bundled/sas/album-index.ts index 8f0b119f..ff0976d9 100644 --- a/sas/static/bundled/sas/album-index.ts +++ b/sas/static/bundled/sas/album-index.ts @@ -17,7 +17,6 @@ document.addEventListener("alpine:init", () => { page: Number.parseInt(initialUrlParams.get("page")) || 1, pushstate: History.Push /* Used to avoid pushing a state on a back action */, loading: false, - config: {} as AlbumConfig, async init() { await this.fetchPictures(); @@ -34,6 +33,13 @@ document.addEventListener("alpine:init", () => { this.config = config; }, + getPage(page: number) { + return this.pictures.slice( + (page - 1) * config.maxPageSize, + config.maxPageSize * page, + ); + }, + async fetchPictures() { this.loading = true; this.pictures = await paginated(picturesFetchPictures, { diff --git a/sas/templates/sas/album.jinja b/sas/templates/sas/album.jinja index 0e5762b8..172e81ab 100644 --- a/sas/templates/sas/album.jinja +++ b/sas/templates/sas/album.jinja @@ -1,6 +1,6 @@ {% extends "core/base.jinja" %} {% from 'core/macros.jinja' import paginate_alpine %} -{% from "sas/download_pictures.jinja" import download_button %} +{% from "sas/macros.jinja" import download_button %} {%- block additional_css -%} @@ -73,7 +73,7 @@

{% trans %}Pictures{% endtrans %}

-