Aggregating channels, filter inoperable.
This commit is contained in:
@@ -7,6 +7,12 @@
|
||||
@update="updateFilter"
|
||||
/>
|
||||
|
||||
<ChannelsFilter
|
||||
:filters="filters"
|
||||
:channels="aggChannels"
|
||||
@update="updateFilter"
|
||||
/>
|
||||
|
||||
<ActorsFilter
|
||||
:filters="filters"
|
||||
:actors="aggActors"
|
||||
@@ -63,10 +69,12 @@ import { parse } from 'path-to-regexp';
|
||||
import navigate from '#/src/navigate.js';
|
||||
import { get } from '#/src/api.js';
|
||||
import events from '#/src/events.js';
|
||||
import { getActorIdentifier, parseActorIdentifier } from '#/src/query.js';
|
||||
|
||||
import Filters from '#/components/filters/filters.vue';
|
||||
import ActorsFilter from '#/components/filters/actors.vue';
|
||||
import TagsFilter from '#/components/filters/tags.vue';
|
||||
import ChannelsFilter from '#/components/filters/channels.vue';
|
||||
import Scene from './tile.vue';
|
||||
import Pagination from '../pagination/pagination.vue';
|
||||
|
||||
@@ -85,19 +93,31 @@ const { pageProps, routeParams, urlParsed } = inject('pageContext');
|
||||
const { scope } = routeParams;
|
||||
|
||||
const {
|
||||
actor,
|
||||
actor: pageActor,
|
||||
tag: pageTag,
|
||||
channel: pageChannel,
|
||||
} = pageProps;
|
||||
|
||||
const scenes = ref(pageProps.scenes);
|
||||
const aggActors = ref(pageProps.aggActors);
|
||||
const aggTags = ref(pageProps.aggTags);
|
||||
const aggChannels = ref(pageProps.aggChannels);
|
||||
|
||||
const currentPage = ref(Number(routeParams.page));
|
||||
const total = ref(Number(pageProps.total));
|
||||
|
||||
const actorIds = urlParsed.search.actors?.split(',').map((identifier) => parseActorIdentifier(identifier)?.id).filter(Boolean) || [];
|
||||
const queryActors = actorIds.map((urlActorId) => aggActors.value.find((aggActor) => aggActor.id === urlActorId)).filter(Boolean);
|
||||
|
||||
const networks = Object.fromEntries(aggChannels.value.map((channel) => (channel.type === 'network' ? channel : channel.parent)).filter(Boolean).map((parent) => [`_${parent.slug}`, parent]));
|
||||
const channels = Object.fromEntries(aggChannels.value.filter((channel) => channel.type === 'channel').map((channel) => [channel.slug, channel]));
|
||||
|
||||
const queryChannel = networks[urlParsed.search.e] || channels[urlParsed.search.e];
|
||||
|
||||
const filters = ref({
|
||||
actors: urlParsed.search.actors?.split(',').filter(Boolean).map((actorId) => Number(actorId)) || [],
|
||||
tags: urlParsed.search.tags?.split(',').filter(Boolean) || [],
|
||||
channel: queryChannel,
|
||||
actors: queryActors,
|
||||
});
|
||||
|
||||
function getPath(targetScope, preserveQuery) {
|
||||
@@ -127,15 +147,16 @@ async function search(resetPage = true) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
const query = {
|
||||
tags: filters.value.tags.join(','),
|
||||
};
|
||||
const query = {};
|
||||
|
||||
console.log('actor id', actor?.id);
|
||||
const entity = filters.value.channel || pageChannel;
|
||||
const entitySlug = entity?.type === 'network' ? `_${entity.slug}` : entity?.slug;
|
||||
|
||||
const res = await get('/scenes', {
|
||||
...query,
|
||||
actors: [actor?.id, filters.value.actors].filter(Boolean).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
actors: [pageActor, ...filters.value.actors].filter(Boolean).map((filterActor) => getActorIdentifier(filterActor)).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
tags: [pageTag?.slug, ...filters.value.tags].filter(Boolean).join(','),
|
||||
entity: entitySlug,
|
||||
scope,
|
||||
page: currentPage.value, // client uses param rather than query pagination
|
||||
});
|
||||
@@ -145,21 +166,19 @@ async function search(resetPage = true) {
|
||||
aggTags.value = res.aggTags;
|
||||
total.value = res.total;
|
||||
|
||||
console.log(scenes.value);
|
||||
|
||||
events.emit('scrollUp');
|
||||
|
||||
navigate(getPath(scope, false), {
|
||||
...query,
|
||||
actors: filters.value.actors.join(',') || undefined, // don't include actor page ID in query, already a parameter
|
||||
actors: filters.value.actors.map((filterActor) => getActorIdentifier(filterActor)).join(',') || undefined, // don't include page actor ID in query, already a parameter
|
||||
tags: filters.value.tags.join(',') || undefined,
|
||||
e: filters.value.channel?.type === 'network' ? `_${filters.value.channel.slug}` : (filters.value.channel?.slug || undefined),
|
||||
}, { redirect: false });
|
||||
}
|
||||
|
||||
function updateFilter(prop, value, reload = true) {
|
||||
filters.value[prop] = value;
|
||||
|
||||
console.log(prop, value);
|
||||
|
||||
if (reload) {
|
||||
search();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user