Added actor revision overviews to actor and user pages.

This commit is contained in:
2024-10-23 01:28:54 +02:00
parent d0cf9bf5d0
commit 05bd7b703d
21 changed files with 424 additions and 219 deletions

View File

@@ -22,42 +22,48 @@
<a
:href="`/user/${profile.username}/stashes`"
class="domain nolink"
:class="{ active: domain === 'stashes' }"
:class="{ active: section === 'stashes' }"
>Stashes</a>
<a
:href="`/user/${profile.username}/alerts`"
class="domain nolink"
:class="{ active: domain === 'alerts' }"
:class="{ active: section === 'alerts' }"
>Alerts</a>
<a
:href="`/user/${profile.username}/templates`"
class="domain nolink"
:class="{ active: domain === 'templates' }"
:class="{ active: section === 'templates' }"
>Templates</a>
<a
:href="`/user/${profile.username}/revisions`"
:href="`/user/${profile.username}/revisions/scenes`"
class="domain nolink"
:class="{ active: domain === 'revisions' }"
>Revisions</a>
:class="{ active: section === 'revisions' && domain === 'scenes' }"
>Scene Revisions</a>
<a
:href="`/user/${profile.username}/revisions/actors`"
class="domain nolink"
:class="{ active: section === 'revisions' && domain === 'actors' }"
>Actor Revisions</a>
</nav>
<Stashes v-if="domain === 'stashes'" />
<Alerts v-if="domain === 'alerts' && profile.id === user?.id" />
<Stashes v-if="section === 'stashes'" />
<Alerts v-if="section === 'alerts' && profile.id === user?.id" />
<Summaries
v-if="domain === 'templates' && profile.id === user?.id"
v-if="section === 'templates' && profile.id === user?.id"
:release="mockupRelease"
/>
</div>
<div
v-if="domain === 'revisions' && profile.id === user?.id"
v-if="section === 'revisions' && profile.id === user?.id"
class="profile-section revisions"
>
<h3 class="section-header heading">Revisions</h3>
<h3 class="section-header heading">{{ domain.slice(0, -1) }} Revisions</h3>
<Revisions context="user" />
</div>
</div>
@@ -73,7 +79,10 @@ import Summaries from '#/components/scenes/summaries.vue';
import Revisions from '#/components/edit/revisions.vue';
const pageContext = inject('pageContext');
const section = pageContext.routeParams.section;
const domain = pageContext.routeParams.domain;
const user = pageContext.user;
const profile = ref(pageContext.pageProps.profile);
@@ -117,6 +126,7 @@ const mockupRelease = {
align-items: center;
justify-content: space-between;
padding: .5rem 1rem;
text-transform: capitalize;
.button {
margin-left: 1rem;
@@ -222,6 +232,11 @@ const mockupRelease = {
padding: 0 1rem;
}
.revisions-nav {
display: flex;
gap: 1rem;
}
@media(--compact) {
.domains {
padding: .5rem 1rem;

View File

@@ -4,19 +4,37 @@ import { fetchUser } from '#/src/users.js';
import { fetchUserStashes } from '#/src/stashes.js';
import { fetchAlerts } from '#/src/alerts.js';
import { fetchSceneRevisions } from '#/src/scenes.js';
import { fetchActorRevisions } from '#/src/actors.js';
async function fetchRevisions(pageContext) {
if (pageContext.routeParams.username !== pageContext.user?.username) {
return {};
}
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'scenes') {
return fetchSceneRevisions(null, {
userId: pageContext.user.id,
limit: 100,
}, pageContext.user);
}
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'actors') {
return fetchActorRevisions(null, {
userId: pageContext.user.id,
limit: 100,
}, pageContext.user);
}
return {};
}
export async function onBeforeRender(pageContext) {
const [profile, alerts, userRevisions] = await Promise.all([
fetchUser(pageContext.routeParams.username, {}, pageContext.user),
pageContext.routeParams.domain === 'stashes' && pageContext.routeParams.username === pageContext.user?.username
pageContext.routeParams.section === 'alerts' && pageContext.routeParams.username === pageContext.user?.username
? fetchAlerts(pageContext.user)
: [],
pageContext.routeParams.domain === 'revisions' && pageContext.routeParams.username === pageContext.user?.username
? fetchSceneRevisions(null, {
userId: pageContext.user.id,
limit: 100,
}, pageContext.user)
: {},
fetchRevisions(pageContext),
]);
if (!profile) {
@@ -28,8 +46,11 @@ export async function onBeforeRender(pageContext) {
actors,
tags,
movies,
avatars,
} = userRevisions;
console.log(userRevisions);
const stashes = await fetchUserStashes(profile.id, pageContext.user);
return {
@@ -43,6 +64,7 @@ export async function onBeforeRender(pageContext) {
actors,
tags,
movies,
avatars,
},
},
};

View File

@@ -1,7 +1,7 @@
import { redirect } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { match } from 'path-to-regexp';
const path = '/user/:username/:domain?';
const path = '/user/:username/:section?/:domain?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -15,7 +15,8 @@ export default (pageContext) => {
return {
routeParams: {
username: matched.params.username,
domain: matched.params.domain || 'stashes',
section: matched.params.section || 'stashes',
domain: matched.params.domain || 'scenes',
},
};
}