forked from DebaucheryLibrarian/traxxx
75 lines
1.3 KiB
JavaScript
75 lines
1.3 KiB
JavaScript
import { graphql } from '../api';
|
|
import { releaseFields } from '../fragments';
|
|
import { curateUser } from '../curate';
|
|
|
|
function initUsersActions(store, _router) {
|
|
async function fetchUser(context, username) {
|
|
const { user } = await graphql(`
|
|
query User(
|
|
$username: String!
|
|
$hasAuth: Boolean!
|
|
$userId: Int
|
|
) {
|
|
user: userByUsername(username: $username) {
|
|
id
|
|
role
|
|
username
|
|
stashes {
|
|
id
|
|
name
|
|
slug
|
|
public
|
|
primary
|
|
actors: stashesActors {
|
|
comment
|
|
actor {
|
|
id
|
|
name
|
|
slug
|
|
gender
|
|
age
|
|
ageFromBirth
|
|
dateOfBirth
|
|
birthCity
|
|
birthState
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
isS3
|
|
width
|
|
height
|
|
}
|
|
}
|
|
}
|
|
scenes: stashesScenes(first: 20) {
|
|
comment
|
|
scene {
|
|
${releaseFields}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`, {
|
|
hasAuth: !!store.state.auth.user,
|
|
userId: store.state.auth.user?.id || null,
|
|
username,
|
|
});
|
|
|
|
return curateUser(user);
|
|
}
|
|
|
|
return {
|
|
fetchUser,
|
|
};
|
|
}
|
|
|
|
export default initUsersActions;
|