traxxx/assets/js/users/actions.js

75 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-03-15 02:30:47 +00:00
import { graphql } from '../api';
2021-03-17 01:09:34 +00:00
import { releaseFields } from '../fragments';
import { curateUser } from '../curate';
function initUsersActions(store, _router) {
async function fetchUser(context, username) {
2021-03-15 02:30:47 +00:00
const { user } = await graphql(`
query User(
$username: String!
$hasAuth: Boolean!
$userId: Int
2021-03-15 02:30:47 +00:00
) {
user: userByUsername(username: $username) {
id
role
username
stashes {
id
name
slug
public
primary
2021-03-15 02:30:47 +00:00
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
2021-03-15 02:30:47 +00:00
}
}
}
scenes: stashesScenes(first: 20) {
2021-03-15 02:30:47 +00:00
comment
scene {
2021-03-17 01:09:34 +00:00
${releaseFields}
2021-03-15 02:30:47 +00:00
}
}
}
}
}
`, {
hasAuth: !!store.state.auth.user,
2021-03-19 20:57:04 +00:00
userId: store.state.auth.user?.id || null,
2021-03-15 02:30:47 +00:00
username,
});
2021-03-17 01:09:34 +00:00
return curateUser(user);
}
return {
fetchUser,
};
}
export default initUsersActions;