mzivil 6355d7eabc
Add nsfw setting to territories (#788)
* add nsfw column to sub

* add nsfw boolean to territorySchema

* save nsfw value in upsertSub mutation

* return nsfw value from Sub query for correct value in edit territory form

* add nsfw checkbox to territory form

* add nsfw badge to territory header

* add nsfwMode to user

* show nsfw badge next to item territory

* exclude nsfw sub from items query

* show nsfw mode checkbox on settings page

* fix nsfw badge formatting

* separate user from current, signed in user

* update relationClause to join with sub table

* refactor to simplify hide nsfw sql

* filter nsfw items when viewing user items

* hide nsfw posts for logged out users

* filter nsfw subs based on user preference

* show nsfw sub name if logged out user is viewing the page

* show current sub at the top of the list instead of bottom

* always join item with sub to check nsfw

* check for sub presence before showing nsfw badge on item

* skip manually adding sub to select if sub is null

* fix relationClause to join with root item

* move moderation and nsfw into accordion

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-09 20:35:32 -06:00

117 lines
2.4 KiB
JavaScript

import { gql } from '@apollo/client'
import { ITEM_FIELDS, ITEM_FULL_FIELDS } from './items'
import { COMMENTS_ITEM_EXT_FIELDS } from './comments'
export const SUB_FIELDS = gql`
fragment SubFields on Sub {
name
postTypes
allowFreebies
rankingType
billingType
billingCost
billingAutoRenew
billedLastAt
baseCost
userId
desc
status
moderated
moderatedCount
meMuteSub
nsfw
}`
export const SUB_FULL_FIELDS = gql`
${SUB_FIELDS}
fragment SubFullFields on Sub {
...SubFields
user {
name
id
optional {
streak
}
}
}`
export const SUB = gql`
${SUB_FIELDS}
query Sub($sub: String) {
sub(name: $sub) {
...SubFields
}
}`
export const SUB_FULL = gql`
${SUB_FULL_FIELDS}
query Sub($sub: String) {
sub(name: $sub) {
...SubFullFields
}
}`
export const SUBS = gql`
${SUB_FIELDS}
query Subs {
subs {
...SubFields
}
}`
export const SUB_ITEMS = gql`
${SUB_FULL_FIELDS}
${ITEM_FIELDS}
${COMMENTS_ITEM_EXT_FIELDS}
query SubItems($sub: String, $sort: String, $cursor: String, $type: String, $name: String, $when: String, $from: String, $to: String, $by: String, $limit: Limit, $includeComments: Boolean = false) {
sub(name: $sub) {
...SubFullFields
}
items(sub: $sub, sort: $sort, cursor: $cursor, type: $type, name: $name, when: $when, from: $from, to: $to, by: $by, limit: $limit) {
cursor
items {
...ItemFields
...CommentItemExtFields @include(if: $includeComments)
position
},
pins {
...ItemFields
...CommentItemExtFields @include(if: $includeComments)
position
}
}
}
`
export const SUB_SEARCH = gql`
${SUB_FIELDS}
${ITEM_FULL_FIELDS}
query SubSearch($sub: String, $q: String, $cursor: String, $sort: String, $what: String, $when: String, $from: String, $to: String) {
sub(name: $sub) {
...SubFields
}
search(sub: $sub, q: $q, cursor: $cursor, sort: $sort, what: $what, when: $when, from: $from, to: $to) {
cursor
items {
...ItemFullFields
searchTitle
searchText
}
}
}
`
export const SUB_PAY = gql`
${SUB_FULL_FIELDS}
mutation paySub($name: String!, $hash: String, $hmac: String) {
paySub(name: $name, hash: $hash, hmac: $hmac) {
...SubFullFields
}
}`