avoid db dip for sub

This commit is contained in:
keyan 2023-05-05 12:38:56 -05:00
parent 7e0103bce3
commit b406f0c340
11 changed files with 16 additions and 22 deletions

View File

@ -118,6 +118,7 @@ export default gql`
location: String
remote: Boolean
sub: Sub
subName: String
status: String
uploadId: Int
otsHash: String

View File

@ -62,7 +62,7 @@ export function BountyForm ({
(async ({ boost, bounty, ...values }) => {
const { error } = await upsertBounty({
variables: {
sub: item?.sub?.name || sub?.name,
sub: item?.subName || sub?.name,
id: item?.id,
boost: boost ? Number(boost) : undefined,
bounty: bounty ? Number(bounty) : undefined,

View File

@ -41,9 +41,9 @@ function Parent ({ item, rootText }) {
<Link href={`/items/${item.root.id}`} passHref>
<a className='text-reset'>{rootText || 'on:'} {item.root.title}</a>
</Link>
{item.root.sub?.name &&
<Link href={`/~${item.root.sub?.name}`}>
<a>{' '}<Badge className={itemStyles.newComment} variant={null}>{item.root.sub?.name}</Badge></a>
{item.root.subName &&
<Link href={`/~${item.root.subName}`}>
<a>{' '}<Badge className={itemStyles.newComment} variant={null}>{item.root.subName}</Badge></a>
</Link>}
</>
)

View File

@ -56,7 +56,7 @@ export function DiscussionForm ({
schema={schema}
onSubmit={handleSubmit || (async ({ boost, ...values }) => {
const { error } = await upsertDiscussion({
variables: { sub: item?.sub?.name || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, ...values }
variables: { sub: item?.subName || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, ...values }
})
if (error) {
throw new Error({ message: error.toString() })

View File

@ -65,9 +65,9 @@ export default function ItemInfo ({ item, commentsText, className, embellishUser
</Link>
</>}
</span>
{item.sub?.name &&
<Link href={`/~${item.sub?.name}`}>
<a>{' '}<Badge className={styles.newComment} variant={null}>{item.sub?.name}</Badge></a>
{item.subName &&
<Link href={`/~${item.subName}`}>
<a>{' '}<Badge className={styles.newComment} variant={null}>{item.subName}</Badge></a>
</Link>}
{(item.outlawed && !item.mine &&
<Link href='/outlawed'>

View File

@ -85,7 +85,7 @@ export function LinkForm ({ item, sub, editThreshold }) {
schema={schema}
onSubmit={async ({ boost, title, ...values }) => {
const { error } = await upsertLink({
variables: { sub: item?.sub?.name || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, title: title.trim(), ...values }
variables: { sub: item?.subName || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, title: title.trim(), ...values }
})
if (error) {
throw new Error({ message: error.toString() })

View File

@ -42,7 +42,7 @@ export function PollForm ({ item, sub, editThreshold }) {
const { error } = await upsertPoll({
variables: {
id: item?.id,
sub: item?.sub?.name || sub?.name,
sub: item?.subName || sub?.name,
boost: boost ? Number(boost) : undefined,
title: title.trim(),
options: optionsFiltered,

View File

@ -31,9 +31,7 @@ export const COMMENT_FIELDS = gql`
title
bounty
bountyPaidTo
sub {
name
}
subName
user {
name
streak

View File

@ -37,10 +37,7 @@ export const ITEM_FIELDS = gql`
company
location
remote
sub {
name
baseCost
}
subName
pollCost
status
uploadId
@ -63,9 +60,7 @@ export const ITEM_FULL_FIELDS = gql`
title
bounty
bountyPaidTo
sub {
name
}
subName
user {
name
streak

View File

@ -14,7 +14,7 @@ export default function PostEdit ({ data: { item } }) {
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
return (
<LayoutCenter sub={item.sub?.name}>
<LayoutCenter sub={item.subName}>
{item.isJob
? <JobForm item={item} sub={item.sub} />
: (item.url

View File

@ -16,7 +16,7 @@ export default function AnItem ({ data: { item } }) {
({ item } = data)
}
const sub = item.sub?.name || item.root?.sub?.name
const sub = item.subName || item.root?.subName
return (
<Layout sub={sub} noSeo>