165 lines
3.8 KiB
JavaScript
165 lines
3.8 KiB
JavaScript
import { graphql } from '../api';
|
|
import { curateRelease, curateActor } from '../curate';
|
|
|
|
function initUiActions(_store, _router) {
|
|
function setFilter({ commit }, filter) {
|
|
commit('setFilter', filter);
|
|
localStorage.setItem('filter', filter);
|
|
}
|
|
|
|
function setRange({ commit }, range) {
|
|
commit('setRange', range);
|
|
}
|
|
|
|
function setBatch({ commit }, batch) {
|
|
commit('setBatch', batch);
|
|
localStorage.setItem('batch', batch);
|
|
}
|
|
|
|
function setTheme({ commit }, theme) {
|
|
commit('setTheme', theme);
|
|
localStorage.setItem('theme', theme);
|
|
}
|
|
|
|
async function setSfw({ commit }, sfw) {
|
|
commit('setSfw', sfw);
|
|
localStorage.setItem('sfw', sfw);
|
|
}
|
|
|
|
async function search({ _commit }, { query, limit = 20 }) {
|
|
const res = await graphql(`
|
|
query SearchReleases(
|
|
$query: String!
|
|
$limit: Int = 20
|
|
) {
|
|
releases: searchReleases(
|
|
query: $query
|
|
first: $limit
|
|
) {
|
|
id
|
|
title
|
|
slug
|
|
date
|
|
url
|
|
type
|
|
isNew
|
|
site {
|
|
id
|
|
slug
|
|
name
|
|
url
|
|
network {
|
|
id
|
|
slug
|
|
name
|
|
url
|
|
}
|
|
}
|
|
actors: releasesActors {
|
|
actor {
|
|
id
|
|
slug
|
|
name
|
|
}
|
|
}
|
|
tags: releasesTags(orderBy: TAG_BY_TAG_ID__PRIORITY_DESC) {
|
|
tag {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
}
|
|
poster: releasesPosterByReleaseId {
|
|
media {
|
|
id
|
|
thumbnail
|
|
lazy
|
|
}
|
|
}
|
|
covers: releasesCovers {
|
|
media {
|
|
id
|
|
thumbnail
|
|
lazy
|
|
}
|
|
}
|
|
}
|
|
actors: searchActors(
|
|
search: $query,
|
|
first: $limit
|
|
) {
|
|
id
|
|
name
|
|
slug
|
|
age
|
|
dateOfBirth
|
|
gender
|
|
aliasFor: actorByAliasFor {
|
|
id
|
|
name
|
|
slug
|
|
age
|
|
dateOfBirth
|
|
gender
|
|
network {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
comment
|
|
copyright
|
|
}
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
}
|
|
network {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
comment
|
|
copyright
|
|
}
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
}
|
|
}
|
|
`, {
|
|
query,
|
|
limit,
|
|
});
|
|
|
|
return {
|
|
releases: res.releases.map(release => curateRelease(release)),
|
|
actors: res.actors.map(actor => curateActor(actor)),
|
|
};
|
|
}
|
|
|
|
return {
|
|
search,
|
|
setFilter,
|
|
setRange,
|
|
setBatch,
|
|
setSfw,
|
|
setTheme,
|
|
};
|
|
}
|
|
|
|
export default initUiActions;
|