Added scene relations.

This commit is contained in:
2026-11-21 02:54:56 +01:00
parent 5ce4c1f63b
commit 78654a62df
12 changed files with 952 additions and 4 deletions
+30
View File
@@ -10,6 +10,7 @@ import Pagination from '#/components/pagination/pagination.vue';
import { get, post } from '#/src/api.js';
import navigate from '#/src/navigate.js';
import { formatDuration } from '#/utils/format.js';
import { getRelationLabel } from '#/utils/relation-labels.js';
defineProps({
context: {
@@ -26,11 +27,28 @@ const actors = ref(pageContext.pageProps.actors);
const tags = ref(pageContext.pageProps.tags);
const movies = ref(pageContext.pageProps.movies);
const avatars = ref(pageContext.pageProps.avatars);
const relationScenes = ref(pageContext.pageProps.relationScenes || []); // not provided for actor revisions
const actorsById = computed(() => Object.fromEntries(actors.value.map((actor) => [actor.id, actor])));
const tagsById = computed(() => Object.fromEntries(tags.value.map((tag) => [tag.id, tag])));
const moviesById = computed(() => Object.fromEntries(movies.value.map((movie) => [movie.id, movie])));
const avatarsById = computed(() => Object.fromEntries(avatars.value.map((avatar) => [avatar.id, avatar])));
const relationScenesById = computed(() => Object.fromEntries(relationScenes.value.map((scene) => [scene.id, scene])));
function getRelationKey(relation) {
return `${relation.direction}:${relation.type}:${relation.sceneId}`;
}
function curateRelation(relation, modified) {
const label = getRelationLabel(relation.type, relation.direction);
const relatedScene = relationScenesById.value[relation.sceneId];
return {
id: getRelationKey(relation),
name: `${label.charAt(0).toLowerCase()}${label.slice(1)} ${relatedScene?.title || `#${relation.sceneId}`}`,
modified,
};
}
const feedbacks = ref({});
const showReviewed = ref(Object.hasOwn(pageContext.urlParsed.search, 'final'));
@@ -90,6 +108,10 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
}))];
}
if (key === 'relations') {
return [key, value.map((relation) => curateRelation(relation, revision.deltas.some((delta) => delta.key === key && !delta.value.some((deltaRelation) => getRelationKey(deltaRelation) === getRelationKey(relation)))))];
}
if (key === 'socials') {
// new socials don't have IDs yet, so we need to compare the values
return [key, value.map((item) => ({
@@ -134,6 +156,13 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
};
}
if (delta.key === 'relations') {
return {
...delta,
value: delta.value.map((relation) => curateRelation(relation, !(revision.base.relations || []).some((baseRelation) => getRelationKey(baseRelation) === getRelationKey(relation)))),
};
}
if (delta.key === 'socials') {
// new socials don't have IDs yet, so we need to compare the values
return {
@@ -187,6 +216,7 @@ async function reloadRevisions() {
actors.value = updatedRevisions.actors;
tags.value = updatedRevisions.tags;
movies.value = updatedRevisions.movies;
relationScenes.value = updatedRevisions.relationScenes || [];
avatars.value = updatedRevisions.avatars;
revisions.value = updatedRevisions.revisions;
total.value = updatedRevisions.total;