Compare commits

..

No commits in common. "11e043ca2e5bb2133d0fdd79e02cbd58d1069c53" and "d4919016b67997741ec3903890d573a2ed60de9d" have entirely different histories.

34 changed files with 178 additions and 653 deletions

View File

@ -34,11 +34,18 @@
class="header-social"
/>
<StashButton
:stashed-by="stashedBy"
class="actor-stash light"
@stash="(stash) => stashActor(stash)"
@unstash="(stash) => unstashActor(stash)"
<Icon
v-show="me && isStashed"
icon="heart7"
class="stash stashed noselect"
@click="unstashActor"
/>
<Icon
v-show="me && !isStashed"
icon="heart8"
class="stash unstashed noselect"
@click="stashActor"
/>
</div>
@ -383,7 +390,6 @@ import Expand from '../expand/expand.vue';
import Scroll from '../scroll/scroll.vue';
import Gender from './gender.vue';
import Social from './social.vue';
import StashButton from '../stashes/button.vue';
async function fetchActor(scroll = true) {
const { actor, releases, totalCount } = await this.$store.dispatch('fetchActorById', {
@ -396,31 +402,38 @@ async function fetchActor(scroll = true) {
this.actor = actor;
this.releases = releases;
this.totalCount = totalCount;
this.stashedBy = actor.stashes;
if (this.$refs.filter && scroll) {
this.$refs.filter.$el.scrollIntoView();
}
}
async function stashActor(stashId) {
this.stashedBy = await this.$store.dispatch('stashActor', {
async function stashActor() {
this.$store.dispatch('stashActor', {
actorId: this.actor.id,
stashId,
stashId: this.$store.getters.favorites.id,
});
this.fetchActor(false);
}
async function unstashActor(stashId) {
this.stashedBy = await this.$store.dispatch('unstashActor', {
async function unstashActor() {
this.$store.dispatch('unstashActor', {
actorId: this.actor.id,
stashId,
stashId: this.$store.getters.favorites.id,
});
this.fetchActor(false);
}
function me() {
return this.$store.state.auth.user;
}
function isStashed() {
return this.actor.stashes?.length > 0;
}
function sfw() {
return this.$store.state.ui.sfw;
}
@ -454,7 +467,6 @@ export default {
Releases,
Gender,
Social,
StashButton,
},
data() {
return {
@ -465,11 +477,10 @@ export default {
pageTitle: null,
bioExpanded: false,
photosExpanded: false,
stashed: false,
stashedBy: [],
};
},
computed: {
isStashed,
me,
sfw,
showAlbum,
@ -505,10 +516,6 @@ export default {
background: var(--profile);
}
.actor-stash {
margin: 0 1rem 0 0;
}
.header-name {
padding: .5rem 1rem;
margin: 0;

View File

@ -113,7 +113,6 @@ export default {
.photo {
height: 15rem;
width: auto;
box-shadow: 0 0 3px var(--darken-weak);
object-fit: cover;
background-position: center;

View File

@ -44,7 +44,7 @@
import Warning from './warning.vue';
import Header from '../header/header.vue';
import Sidebar from '../sidebar/sidebar.vue';
import Filters from '../filters/filters.vue';
import Filters from './filters.vue';
function toggleSidebar(state) {
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
@ -124,6 +124,8 @@ export default {
</script>
<style lang="scss">
@import 'theme';
.container {
position: relative;
height: 100%;

View File

@ -1,6 +1,6 @@
<template>
<Dialog
title="Filters"
title="filters"
@close="$emit('close')"
>
<div class="filters">

View File

@ -76,6 +76,7 @@ export default {
color: var(--text-light);
font-size: 1.5rem;
font-weight: bold;
text-transform: capitalize;
}
.header-title {
@ -105,11 +106,7 @@ export default {
::v-deep(.dialog-actions) {
display: flex;
padding: 1rem 0 0 0;
&.center {
justify-content: center;
}
padding: .5rem 0;
&.right {
justify-content: flex-end;

View File

@ -1,8 +1,5 @@
<template>
<label
class="toggle-container noselect"
:class="{ light: $store.state.ui.theme === 'dark' }"
>
<label class="toggle-container noselect">
<input
:id="`toggle-${id}`"
:checked="checked"

View File

@ -3,7 +3,6 @@
v-if="release"
ref="content"
class="content"
@scroll="events.emit('scroll', $event)"
>
<Scroll
v-slot="slotProps"
@ -52,10 +51,18 @@
/>
</h2>
<StashButton
:stashed-by="stashedBy"
@stash="(stash) => stashScene(stash)"
@unstash="(stash) => unstashScene(stash)"
<Icon
v-show="me && release.isStashed"
icon="heart7"
class="stash stashed noselect"
@click="unstashScene"
/>
<Icon
v-show="me && !release.isStashed"
icon="heart8"
class="stash unstashed noselect"
@click="stashScene"
/>
</div>
@ -223,7 +230,6 @@
<script>
import Details from './details.vue';
import Banner from './banner.vue';
import StashButton from '../stashes/button.vue';
import Album from '../album/album.vue';
import Tags from './tags.vue';
import Chapters from './chapters.vue';
@ -243,24 +249,26 @@ async function fetchRelease(scroll = true) {
if (scroll && this.$refs.content) {
this.$refs.content.scrollTop = 0;
}
this.stashedBy = this.release.stashes;
}
async function stashScene(stashId) {
this.stashedBy = await this.$store.dispatch(this.$route.name === 'movie' ? 'stashMovie' : 'stashScene', {
async function stashScene() {
this.$store.dispatch(this.$route.name === 'movie' ? 'stashMovie' : 'stashScene', {
sceneId: this.release.id,
movieId: this.release.id,
stashId,
stashId: this.$store.getters.favorites.id,
});
this.fetchRelease(false);
}
async function unstashScene(stashId) {
this.stashedBy = await this.$store.dispatch(this.$route.name === 'movie' ? 'unstashMovie' : 'unstashScene', {
async function unstashScene() {
this.$store.dispatch(this.$route.name === 'movie' ? 'unstashMovie' : 'unstashScene', {
sceneId: this.release.id,
movieId: this.release.id,
stashId,
stashId: this.$store.getters.favorites.id,
});
this.fetchRelease(false);
}
function me() {
@ -286,18 +294,16 @@ export default {
components: {
Actor,
Album,
Banner,
Chapters,
Details,
Releases,
Banner,
Scroll,
StashButton,
Releases,
Chapters,
Tags,
},
data() {
return {
release: null,
stashedBy: [],
};
},
computed: {
@ -388,6 +394,22 @@ export default {
color: var(--shadow);
}
.stash.icon {
width: 1.5rem;
height: 1.5rem;
padding: 0 1rem;
fill: var(--darken);
&.stashed {
fill: var(--primary);
}
&:hover {
fill: var(--primary);
cursor: pointer;
}
}
.album-toggle {
height: fit-content;
display: inline-flex;

View File

@ -451,7 +451,7 @@ export default {
.tile.new .poster::after {
bottom: 0;
top: auto;
margin: .1rem .25rem;
margin: 0 .25rem;
}
.stash {

View File

@ -1,99 +0,0 @@
<template>
<span class="stash-container">
<Tooltip class="stash-trigger">
<Icon
v-show="me"
icon="menu"
class="stash noselect"
:class="{ stashed }"
/>
<template v-slot:tooltip>
<StashMenu
:stashed-by="stashedBy"
@stash="(stashId) => $emit('stash', stashId)"
@unstash="(stashId) => $emit('unstash', stashId)"
/>
</template>
</Tooltip>
<Icon
v-show="me && favorited"
icon="heart7"
class="stash stashed noselect"
@click.native="() => $emit('unstash', favorites.id)"
/>
<Icon
v-show="me && !favorited"
icon="heart8"
class="stash unstashed noselect"
@click.native="() => $emit('stash', favorites.id)"
/>
</span>
</template>
<script>
import StashMenu from './menu.vue';
function favorited() {
return this.stashedBy.some(stash => stash.primary);
}
function stashed() {
return this.stashedBy.some(stash => !stash.primary);
}
function favorites() {
return this.$store.getters.favorites;
}
function me() {
return this.$store.state.auth.user;
}
export default {
components: {
StashMenu,
},
props: {
stashedBy: {
type: Array,
default: () => [],
},
},
emits: ['stash', 'unstash'],
computed: {
me,
favorites,
favorited,
stashed,
},
};
</script>
<style lang="scss" scoped>
.stash-container.light .icon {
fill: var(--lighten);
}
.stash.icon {
width: 1.5rem;
height: 1.5rem;
padding: 0 .5rem;
fill: var(--shadow);
&.stashed {
fill: var(--primary);
}
&:hover {
fill: var(--primary);
cursor: pointer;
}
}
.stash-trigger {
display: inline-block;
}
</style>

View File

@ -1,70 +0,0 @@
<template>
<ul class="menu nolist">
<li
v-for="stash in stashes"
:key="`stash-${stash.id}`"
class="menu-item"
>
<label class="menu-stash noselect">
<Checkbox
:checked="stashedByIds.has(stash.id)"
class="menu-check"
@change="(checked) => checked ? $emit('stash', stash.id) : $emit('unstash', stash.id)"
/>{{ stash.name }}
</label>
</li>
</ul>
</template>
<script>
import Checkbox from '../form/checkbox.vue';
function stashes() {
return this.$store.state.auth.user?.stashes || [];
}
export default {
components: {
Checkbox,
},
props: {
stashedBy: {
type: Array,
default: () => [],
},
},
emits: ['stash', 'unstash'],
data() {
const stashedByIds = new Set(this.stashedBy.map(stash => stash.id));
return {
stashedByIds,
};
},
computed: {
stashes,
},
};
</script>
<style lang="scss" scoped>
.menu-item {
display: block;
}
.menu-stash {
display: flex;
align-items: center;
padding: .5rem 1rem .5rem .5rem;
&:hover {
color: var(--primary);
cursor: pointer;
}
}
.menu-check {
display: inline-block;
margin: 0 .75rem 0 0;
}
</style>

View File

@ -1,38 +0,0 @@
<template>
<Dialog
title="Remove stash"
@close="$emit('close', false)"
>
<form @submit.prevent="removeStash">
Are you sure you want to remove stash "{{ stash.name }}"?
<div class="dialog-actions right">
<button
type="submit"
class="button button-primary"
>Remove</button>
</div>
</form>
</Dialog>
</template>
<script>
async function removeStash() {
await this.$store.dispatch('removeStash', this.stash.id);
this.$emit('close', true);
}
export default {
props: {
stash: {
type: Object,
default: null,
},
},
emits: ['close'],
methods: {
removeStash,
},
};
</script>

View File

@ -4,18 +4,9 @@
class="stash content"
>
<div class="stash-header">
<h2
:title="stash.name"
class="stash-name"
>{{ stash.name }}</h2>
<h2 class="stash-name">{{ stash.name }}</h2>
<span class="header-section">
<router-link
v-if="stash.user"
:to="{ name: 'user', params: { username: stash.user.username } }"
class="header-item stash-username nolink"
><Icon icon="user3" /><span class="username-name">{{ stash.user.username }}</span></router-link>
<label
v-if="isMine"
v-tooltip="'Public'"
@ -39,18 +30,11 @@
/>
</label>
<Icon
v-if="isMine && !stash.primary"
icon="bin"
class="stash-remove"
@click.native="showRemoveStash = true"
/>
<RemoveStash
v-if="showRemoveStash"
:stash="stash"
@close="removeStash"
/>
<router-link
v-if="stash.user"
:to="{ name: 'user', params: { username: stash.user.username } }"
class="header-item stash-username nolink"
><Icon icon="user3" />{{ stash.user.username }}</router-link>
</span>
</div>
@ -78,7 +62,6 @@
<script>
import Actor from '../actors/tile.vue';
import Releases from '../releases/releases.vue';
import RemoveStash from './remove-stash.vue';
import Toggle from '../form/toggle.vue';
async function fetchStash() {
@ -95,19 +78,6 @@ async function publishStash(isPublic) {
this.fetchStash();
}
async function removeStash(removed) {
this.showRemoveStash = false;
if (removed && this.stash.user) {
this.$router.replace({ name: 'user', params: { username: this.stash.user.username } });
return;
}
if (removed) {
this.$router.replace({ name: 'home' });
}
}
async function mounted() {
this.fetchStash();
}
@ -116,13 +86,11 @@ export default {
components: {
Actor,
Releases,
RemoveStash,
Toggle,
},
data() {
return {
stash: null,
showRemoveStash: false,
isMine: false,
};
},
@ -130,14 +98,11 @@ export default {
methods: {
fetchStash,
publishStash,
removeStash,
},
};
</script>
<style lang="scss" scoped>
@import 'breakpoints';
.stash-header {
display: flex;
justify-content: space-between;
@ -158,29 +123,12 @@ export default {
align-items: center;
}
.stash-name,
.stash-username {
box-sizing: border-box;
padding: .5rem 1rem;
font-weight: bold;
}
.stash-username {
display: inline-flex;
align-items: center;
margin: 0 .5rem 0 0;
}
.stash-name {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
.header-item:not(:last-child) {
margin: 0 1rem 0 0;
}
.stash-public {
cursor: pointer;
margin: 0 .5rem 0 0;
.icon {
margin: 0 .75rem 0 0;
@ -188,15 +136,13 @@ export default {
}
}
.stash-remove.icon {
height: 100%;
padding: 0 1rem;
fill: var(--lighten-strong);
&:hover {
fill: var(--text-light);
cursor: pointer;
}
.stash-name,
.stash-username {
display: inline-flex;
align-items: center;
padding: .5rem 1rem;
margin: 0;
font-weight: bold;
}
.stash-section:not(:last-child) {
@ -218,18 +164,4 @@ export default {
grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
}
}
@media(max-width: $breakpoint-small) {
.stash-name {
font-size: 1.25rem;
}
.username-name {
display: none;
}
.stash-username {
margin: 0;
}
}
</style>

View File

@ -63,7 +63,7 @@ export default {
align-items: center;
position: absolute;
left: 0;
background: var(--darken-weak);
background: var(--shadow-weak);
color: var(--text-light);
font-size: .7rem;
font-weight: bold;

View File

@ -6,10 +6,8 @@
class="stash-link nolink"
>
<h4 class="stash-name">{{ stash.name }}</h4>
<span class="stash-more">Browse</span>
</router-link>
<span class="header-actions noselect">
<label
v-if="isMe"
v-tooltip="'Public'"
@ -28,23 +26,9 @@
<Toggle
:checked="stash.public"
@change="checked => publishStash(checked)"
@change="checked => publishStash(stash, checked)"
/>
</label>
<Icon
v-if="isMe && !stash.primary"
icon="bin"
class="stash-remove"
@click.native="showRemoveStash = true"
/>
<RemoveStash
v-if="showRemoveStash"
:stash="stash"
@close="removeStash"
/>
</span>
</div>
<ul
@ -84,31 +68,21 @@
<script>
import ActorPreview from './actor-preview.vue';
import ScenePreview from './scene-preview.vue';
import RemoveStash from '../stashes/remove-stash.vue';
import Toggle from '../form/toggle.vue';
async function publishStash(isPublic) {
async function publishStash(stash, isPublic) {
await this.$store.dispatch('updateStash', {
stashId: this.stash.id,
stashId: stash.id,
stash: { public: isPublic },
});
this.$emit('publish', isPublic);
}
async function removeStash(removed) {
this.showRemoveStash = false;
if (removed) {
this.$emit('remove');
}
}
export default {
components: {
ActorPreview,
ScenePreview,
RemoveStash,
Toggle,
},
props: {
@ -121,15 +95,9 @@ export default {
default: false,
},
},
emits: ['publish', 'remove'],
data() {
return {
showRemoveStash: false,
};
},
emits: ['publish'],
methods: {
publishStash,
removeStash,
},
};
</script>
@ -155,46 +123,17 @@ export default {
.stash-header {
justify-content: space-between;
align-items: stretch;
padding: 0;
}
.stash-link {
display: inline-flex;
align-items: center;
flex-grow: 1;
text-decoration: none;
overflow: hidden;
&:hover .stash-more {
color: var(--primary);
}
}
.stash-name {
display: inline-block;
padding: 0 .5rem;
margin: 0;
color: var(--shadow-strong);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.stash-more {
flex-shrink: 0;
margin: 0 0 0 .5rem;
color: var(--shadow);
font-size: .9rem;
}
.header-actions {
display: flex;
align-items: stretch;
text-decoration: none;
}
.stash-public {
display: inline-flex;
display: flex;
align-items: center;
padding: .5rem;
cursor: pointer;
@ -205,15 +144,10 @@ export default {
}
}
.stash-remove {
height: auto;
padding: 0 .5rem 0 .75rem;
fill: var(--shadow);
&:hover {
cursor: pointer;
fill: var(--shadow-strong);
}
.stash-name {
padding: .5rem;
margin: 0;
color: var(--shadow-strong);
}
.stash-actors,

View File

@ -11,33 +11,23 @@
v-if="user.stashes?.length > 0"
class="section"
>
<div class="section-header">
<h3 class="section-heading">Stashes</h3>
<h3 class="heading">Stashes</h3>
<Icon
icon="plus3"
class="header-add"
@click="showAddStash = true"
/>
</div>
<ul class="section-body stashes nolist">
<ul class="stashes nolist">
<li
v-for="stash in user.stashes"
:key="stash.id"
class="stashes-stash"
>
<Stash
:stash="stash"
:is-me="isMe"
@publish="() => fetchUser()"
@remove="() => fetchUser()"
/>
</li>
<li
v-if="isMe"
class="stashes-stash stashes-add"
class="stashes-add"
@click="showAddStash = true"
>
<Icon icon="plus2" />
@ -102,23 +92,18 @@ export default {
@import 'breakpoints';
.header {
display: flex;
justify-content: space-between;
padding: .5rem 1rem;
background: var(--profile);
}
.username {
padding: .5rem 1rem;
margin: 0;
font-size: 1.5rem;
color: var(--text-light);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.section {
padding: 1rem 0;
padding: 1rem;
margin: 0 0 1rem 0;
}
@ -129,37 +114,8 @@ export default {
grid-gap: 1rem;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 0 1rem 0;
}
.section-body {
padding: 0 1rem;
}
.section-heading {
.heading {
color: var(--primary);
padding: 0 1rem;
margin: 0;
font-size: 1.25rem;
}
.header-add {
height: auto;
padding: .5rem 1rem;
fill: var(--shadow);
&:hover {
fill: var(--primary);
cursor: pointer;
}
}
.stashes-stash {
min-width: 0;
}
.stashes-add {
@ -167,20 +123,20 @@ export default {
display: flex;
align-items: center;
justify-content: center;
background: var(--shadow-touch);
background: var(--shadow-hint);
.icon {
width: 1.5rem;
height: 1.5rem;
fill: var(--shadow-hint);
fill: var(--shadow-weak);
}
&:hover {
background: var(--shadow-hint);
background: var(--shadow-weak);
cursor: pointer;
.icon {
fill: var(--shadow-weak);
fill: var(--shadow);
}
}
}

View File

@ -26,14 +26,12 @@ $breakpoint4: 1500px;
--darken-censor: rgba(0, 0, 0, .95);
--darken-weak: rgba(0, 0, 0, .2);
--darken-hint: rgba(0, 0, 0, .1);
--darken-touch: rgba(0, 0, 0, .05);
--lighten: rgba(255, 255, 255, .5);
--lighten-strong: rgba(255, 255, 255, .7);
--lighten-extreme: rgba(255, 255, 255, .9);
--lighten-weak: rgba(255, 255, 255, .2);
--lighten-hint: rgba(255, 255, 255, .05);
--lighten-touch: rgba(255, 255, 255, .03);
--logo-shadow: drop-shadow(1px 0 0 $shadow-weak) drop-shadow(-1px 0 0 $shadow-weak) drop-shadow(0 1px 0 $shadow-weak) drop-shadow(0 -1px 0 $shadow-weak);
--logo-highlight: drop-shadow(0 0 1px $highlight);

View File

@ -246,7 +246,6 @@ function initActorActions(store, router) {
}
totalCount
}
isStashed
stashes: stashesActors(
filter: {
stash: {
@ -260,7 +259,6 @@ function initActorActions(store, router) {
id
name
slug
primary
}
}
}

View File

@ -66,12 +66,6 @@ async function del(endpoint) {
credentials: 'same-origin',
});
const contentTypes = res.headers.get('content-type');
if (res.ok && contentTypes?.includes('application/json')) {
return res.json();
}
if (res.ok) {
return true;
}

View File

@ -56,10 +56,6 @@ function curateActor(actor, release) {
curatedActor.aliasFor = curateActor(curatedActor.aliasFor);
}
if (actor.stashes) {
curatedActor.stashes = actor.stashes.filter(Boolean).map(stash => curateStash(stash.stash || stash)); // eslint-disable-line no-use-before-define
}
curatedActor.stashes = actor.stashes?.map(stash => stash.stash || stash) || [];
return curatedActor;
@ -84,7 +80,6 @@ function curateRelease(release) {
if (release.directors) curatedRelease.directors = release.directors.filter(Boolean).map(director => curateActor(director.director || director, curatedRelease));
if (release.movieTags && release.movieTags.length > 0) curatedRelease.tags = release.movieTags.filter(Boolean).map(({ tag }) => tag);
if (release.movieActors && release.movieActors.length > 0) curatedRelease.actors = release.movieActors.filter(Boolean).map(({ actor }) => curateActor(actor, curatedRelease));
if (release.stashes) curatedRelease.stashes = release.stashes.filter(Boolean).map(stash => curateStash(stash.stash || stash)); // eslint-disable-line no-use-before-define
if (release.productionLocation) {
curatedRelease.productionLocation = {
@ -160,7 +155,7 @@ function curateUser(user) {
const curatedUser = user;
if (user.stashes) {
curatedUser.stashes = user.stashes.map(stash => curateStash(stash.stash || stash));
curatedUser.stashes = user.stashes.map(stash => curateStash(stash));
}
return curatedUser;

View File

@ -228,8 +228,7 @@ const releaseFields = `
url
}
isNew
isFavorited
isStashed(includeFavorites: false)
isStashed
stashes: stashesScenesBySceneId(
filter: {
stash: {
@ -243,7 +242,6 @@ const releaseFields = `
id
name
slug
primary
}
}
`;
@ -370,8 +368,7 @@ const releaseFragment = `
}
}
}
isFavorited
isStashed(includeFavorites: false)
isStashed
stashes: stashesScenesBySceneId(
filter: {
stash: {
@ -385,7 +382,6 @@ const releaseFragment = `
id
name
slug
primary
}
}
}

View File

@ -273,7 +273,6 @@ function initReleasesActions(store, router) {
id
name
slug
primary
}
}
}

View File

@ -21,7 +21,6 @@ function initStashesActions(store, _router) {
name
slug
public
primary
user {
id
username
@ -69,45 +68,44 @@ function initStashesActions(store, _router) {
}
async function createStash(context, stash) {
return post('/stashes', stash);
const newStash = await post('/stashes', stash);
return newStash;
}
async function updateStash(context, { stashId, stash }) {
return patch(`/stashes/${stashId}`, stash);
}
const newStash = await patch(`/stashes/${stashId}`, stash);
async function removeStash(context, stashId) {
await del(`/stashes/${stashId}`);
return newStash;
}
async function stashActor(context, { actorId, stashId }) {
return post(`/stashes/${stashId}/actors`, { actorId });
await post(`/stashes/${stashId}/actors`, { actorId });
}
async function unstashActor(context, { actorId, stashId }) {
return del(`/stashes/${stashId}/actors/${actorId}`);
await del(`/stashes/${stashId}/actors/${actorId}`);
}
async function stashScene(context, { sceneId, stashId }) {
return post(`/stashes/${stashId}/scenes`, { sceneId });
await post(`/stashes/${stashId}/scenes`, { sceneId });
}
async function unstashScene(context, { sceneId, stashId }) {
return del(`/stashes/${stashId}/scenes/${sceneId}`);
await del(`/stashes/${stashId}/scenes/${sceneId}`);
}
async function stashMovie(context, { movieId, stashId }) {
return post(`/stashes/${stashId}/movies`, { movieId });
await post(`/stashes/${stashId}/movies`, { movieId });
}
async function unstashMovie(context, { movieId, stashId }) {
return del(`/stashes/${stashId}/movies/${movieId}`);
await del(`/stashes/${stashId}/movies/${movieId}`);
}
return {
createStash,
fetchStash,
removeStash,
stashActor,
stashScene,
stashMovie,

View File

@ -19,7 +19,6 @@ function initUsersActions(store, _router) {
name
slug
public
primary
actors: stashesActors {
comment
actor {

View File

@ -1067,10 +1067,6 @@ exports.up = knex => Promise.resolve()
.notNullable()
.defaultTo(false);
table.boolean('primary')
.notNullable()
.defaultTo(false);
table.datetime('created_at')
.notNullable()
.defaultTo(knex.fn.now());

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{
"name": "traxxx",
"version": "1.190.0",
"version": "1.189.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "1.190.0",
"version": "1.189.1",
"license": "ISC",
"dependencies": {
"@casl/ability": "^5.2.2",

View File

@ -1,6 +1,6 @@
{
"name": "traxxx",
"version": "1.190.0",
"version": "1.189.1",
"description": "All the latest porn releases in one place",
"main": "src/app.js",
"scripts": {

View File

@ -80,7 +80,6 @@ async function signup(credentials) {
name: 'Favorites',
slug: 'favorites',
public: false,
primary: true,
});
return fetchUser(userId);

View File

@ -13,7 +13,6 @@ function curateStash(stash) {
id: stash.id,
name: stash.name,
slug: stash.slug,
primary: stash.primary,
};
return curatedStash;
@ -49,18 +48,6 @@ async function fetchStash(stashId, sessionUser) {
return curateStash(stash);
}
async function fetchStashes(domain, itemId, sessionUser) {
const stashes = await knex(`stashes_${domain}s`)
.select('stashes.*')
.where({
[`${domain}_id`]: itemId,
user_id: sessionUser.id,
})
.leftJoin('stashes', 'stashes.id', `stashes_${domain}s.stash_id`);
return stashes.map(stash => curateStash(stash));
}
async function createStash(newStash, sessionUser) {
if (!sessionUser) {
throw new HttpError('You are not authenthicated', 401);
@ -93,24 +80,6 @@ async function updateStash(stashId, newStash, sessionUser) {
return curateStash(stash);
}
async function removeStash(stashId, sessionUser) {
if (!sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
const removed = await knex('stashes')
.where({
id: stashId,
user_id: sessionUser.id,
primary: false,
})
.delete();
if (removed === 0) {
throw new HttpError('Unable to remove this stash', 400);
}
}
async function stashActor(actorId, stashId, sessionUser) {
const stash = await fetchStash(stashId, sessionUser);
@ -119,8 +88,6 @@ async function stashActor(actorId, stashId, sessionUser) {
stash_id: stash.id,
actor_id: actorId,
});
return fetchStashes('actor', actorId, sessionUser);
}
async function stashScene(sceneId, stashId, sessionUser) {
@ -131,8 +98,6 @@ async function stashScene(sceneId, stashId, sessionUser) {
stash_id: stash.id,
scene_id: sceneId,
});
return fetchStashes('scene', sceneId, sessionUser);
}
async function stashMovie(movieId, stashId, sessionUser) {
@ -143,8 +108,6 @@ async function stashMovie(movieId, stashId, sessionUser) {
stash_id: stash.id,
movie_id: movieId,
});
return fetchStashes('movie', movieId, sessionUser);
}
async function unstashActor(actorId, stashId, sessionUser) {
@ -157,8 +120,6 @@ async function unstashActor(actorId, stashId, sessionUser) {
.where('stashes_actors.stash_id', knex.raw('deletable.stash_id'))
.where('stashes.user_id', sessionUser.id))
.delete();
return fetchStashes('actor', actorId, sessionUser);
}
async function unstashScene(sceneId, stashId, sessionUser) {
@ -171,8 +132,6 @@ async function unstashScene(sceneId, stashId, sessionUser) {
.where('stashes_scenes.stash_id', knex.raw('deletable.stash_id'))
.where('stashes.user_id', sessionUser.id))
.delete();
return fetchStashes('scene', sceneId, sessionUser);
}
async function unstashMovie(movieId, stashId, sessionUser) {
@ -185,14 +144,11 @@ async function unstashMovie(movieId, stashId, sessionUser) {
.where('stashes_movies.stash_id', knex.raw('deletable.stash_id'))
.where('stashes.user_id', sessionUser.id))
.delete();
return fetchStashes('movie', movieId, sessionUser);
}
module.exports = {
createStash,
curateStash,
removeStash,
stashActor,
stashScene,
stashMovie,

View File

@ -26,7 +26,7 @@ function curateUser(user) {
async function fetchUser(userId, raw) {
const user = await knex('users')
.select(knex.raw('users.*, users_roles.abilities as role_abilities, COALESCE(json_agg(stashes ORDER BY stashes.created_at) FILTER (WHERE stashes.id IS NOT NULL), \'[]\') as stashes'))
.select(knex.raw('users.*, users_roles.abilities as role_abilities, COALESCE(json_agg(stashes) FILTER (WHERE stashes.id IS NOT NULL), \'[]\') as stashes'))
.modify((builder) => {
if (typeof userId === 'number') {
builder.where('users.id', userId);

View File

@ -22,7 +22,7 @@ async function logoutApi(req, res) {
async function fetchMeApi(req, res) {
if (req.session.user) {
req.session.user = await fetchUser(req.session.user.id, false, req.session.user);
req.session.user = await fetchUser(req.session.user.id, req.session.user);
res.send(req.session.user);
return;

View File

@ -12,8 +12,6 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({
}
extend type Actor {
isFavorited: Boolean @requires(columns: ["stashesActors"])
isStashed(includeFavorites: Boolean = false): Boolean @requires(columns: ["stashesActors"])
ageFromBirth: Int @requires(columns: ["dateOfBirth"])
ageAtDeath: Int @requires(columns: ["dateOfBirth", "dateOfDeath"])
height(units:Units): String @requires(columns: ["height"])
@ -24,24 +22,6 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({
`,
resolvers: {
Actor: {
isFavorited(parent) {
if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') {
return null;
}
return parent['@stashes'].some(({ '@stash': stash }) => stash.primary);
},
isStashed(parent, args) {
if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') {
return null;
}
if (args.includeFavorites) {
return parent['@stashes'].length > 0;
}
return parent['@stashes'].some(({ '@stash': stash }) => !stash.primary);
},
ageFromBirth(parent, _args, _context, _info) {
if (!parent.dateOfBirth) return null;

View File

@ -5,29 +5,17 @@ const { makeExtendSchemaPlugin, gql } = require('graphile-utils');
const schemaExtender = makeExtendSchemaPlugin(_build => ({
typeDefs: gql`
extend type Release {
isFavorited: Boolean @requires(columns: ["stashesScenesBySceneId"])
isStashed(includeFavorites: Boolean = false): Boolean @requires(columns: ["stashesScenesBySceneId"])
isStashed: Boolean @requires(columns: ["stashesScenesBySceneId"])
}
`,
resolvers: {
Release: {
isFavorited(parent) {
if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') {
isStashed(parent) {
if (!parent['@stashes']) {
return null;
}
return parent['@stashes'].some(({ '@stash': stash }) => stash.primary);
},
isStashed(parent, args) {
if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') {
return null;
}
if (args.includeFavorites) {
return parent['@stashes'].length > 0;
}
return parent['@stashes'].some(({ '@stash': stash }) => !stash.primary);
},
},
},

View File

@ -45,7 +45,6 @@ const {
const {
createStash,
removeStash,
stashActor,
stashScene,
stashMovie,
@ -88,7 +87,6 @@ async function initServer() {
router.post('/api/stashes', createStash);
router.patch('/api/stashes/:stashId', updateStash);
router.delete('/api/stashes/:stashId', removeStash);
router.post('/api/stashes/:stashId/actors', stashActor);
router.post('/api/stashes/:stashId/scenes', stashScene);

View File

@ -2,7 +2,6 @@
const {
createStash,
removeStash,
stashActor,
stashScene,
stashMovie,
@ -24,51 +23,44 @@ async function updateStashApi(req, res) {
res.send(stash);
}
async function removeStashApi(req, res) {
await removeStash(req.params.stashId, req.session.user);
async function stashActorApi(req, res) {
await stashActor(req.body.actorId, req.params.stashId, req.session.user);
res.status(201).send();
}
async function stashSceneApi(req, res) {
await stashScene(req.body.sceneId, req.params.stashId, req.session.user);
res.status(201).send();
}
async function stashMovieApi(req, res) {
await stashMovie(req.body.movieId, req.params.stashId, req.session.user);
res.status(201).send();
}
async function unstashActorApi(req, res) {
await unstashActor(req.params.actorId, req.params.stashId, req.session.user);
res.status(204).send();
}
async function stashActorApi(req, res) {
const stashes = await stashActor(req.body.actorId, req.params.stashId, req.session.user);
res.send(stashes);
}
async function stashSceneApi(req, res) {
const stashes = await stashScene(req.body.sceneId, req.params.stashId, req.session.user);
res.send(stashes);
}
async function stashMovieApi(req, res) {
const stashes = await stashMovie(req.body.movieId, req.params.stashId, req.session.user);
res.send(stashes);
}
async function unstashActorApi(req, res) {
const stashes = await unstashActor(req.params.actorId, req.params.stashId, req.session.user);
res.send(stashes);
}
async function unstashSceneApi(req, res) {
const stashes = await unstashScene(req.params.sceneId, req.params.stashId, req.session.user);
await unstashScene(req.params.sceneId, req.params.stashId, req.session.user);
res.send(stashes);
res.status(204).send();
}
async function unstashMovieApi(req, res) {
const stashes = await unstashMovie(req.params.movieId, req.params.stashId, req.session.user);
await unstashMovie(req.params.movieId, req.params.stashId, req.session.user);
res.send(stashes);
res.status(204).send();
}
module.exports = {
createStash: createStashApi,
removeStash: removeStashApi,
stashActor: stashActorApi,
stashScene: stashSceneApi,
stashMovie: stashMovieApi,