Added pagination and total to revisions.

This commit is contained in:
2026-09-18 03:31:28 +02:00
parent cd10f14285
commit b5e9886b9b
10 changed files with 69 additions and 15 deletions
@@ -10,10 +10,12 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
avatars,
} = await fetchActorRevisions(null, {
isFinalized: false,
limit: 50,
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
return {
@@ -21,6 +23,7 @@ export async function onBeforeRender(pageContext) {
title: pageContext.routeParams.section,
pageProps: {
revisions,
revisionTotal,
avatars,
},
},
+3 -1
View File
@@ -1,6 +1,6 @@
import { match } from 'path-to-regexp';
const path = '/admin/:section/:domain(actors)';
const path = '/admin/:section/:domain(actors)/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -11,6 +11,8 @@ export default (pageContext) => {
routeParams: {
section: matched.params.section,
domain: matched.params.domain,
page: matched.params.page || '1',
path,
},
};
}
@@ -10,12 +10,14 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
actors,
tags,
movies,
} = await fetchSceneRevisions(null, {
isFinalized: false,
limit: 50,
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
return {
@@ -23,6 +25,7 @@ export async function onBeforeRender(pageContext) {
title: pageContext.routeParams.section,
pageProps: {
revisions,
revisionTotal,
actors,
tags,
movies,
+3 -1
View File
@@ -1,6 +1,6 @@
import { match } from 'path-to-regexp';
const path = '/admin/:section/:domain(scenes)';
const path = '/admin/:section/:domain(scenes)/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -11,6 +11,8 @@ export default (pageContext) => {
routeParams: {
section: matched.params.section,
domain: matched.params.domain,
page: matched.params.page || '1',
path,
},
};
}
+6 -2
View File
@@ -15,14 +15,16 @@ async function fetchRevisions(pageContext) {
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'scenes') {
return fetchSceneRevisions(null, {
userId: pageContext.user.id,
limit: 100,
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
}
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'actors') {
return fetchActorRevisions(null, {
userId: pageContext.user.id,
limit: 100,
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
}
@@ -47,6 +49,7 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
actors,
tags,
movies,
@@ -63,6 +66,7 @@ export async function onBeforeRender(pageContext) {
stashes,
alerts,
revisions,
revisionTotal,
keys,
actors,
tags,
+3 -1
View File
@@ -1,7 +1,7 @@
import { match } from 'path-to-regexp';
import { redirect } from 'vike/abort';
const path = '/user/:username/:section?/:domain?';
const path = '/user/:username/:section?/:domain?/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -18,6 +18,8 @@ export default (pageContext) => {
username: matched.params.username,
section: matched.params.section || '',
domain: matched.params.domain || '',
page: matched.params.page || '1',
path,
},
};
}