fix bio quirks
This commit is contained in:
parent
c400a6c1c6
commit
5fab3abb82
|
@ -23,8 +23,8 @@ export async function getCost ({ subName, parentId, uploadIds, boost = 0, bio },
|
|||
|
||||
// sub allows freebies (or is a bio or a comment), cost is less than baseCost, not anon,
|
||||
// cost must be greater than user's balance, and user has not disabled freebies
|
||||
const freebie = (parentId || bio) && cost <= baseCost && !!me &&
|
||||
cost > me?.msats && !me?.disableFreebies
|
||||
const freebie = bio || (parentId && cost <= baseCost && !!me &&
|
||||
cost > me?.msats && !me?.disableFreebies)
|
||||
|
||||
return freebie ? BigInt(0) : BigInt(cost)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ export const anonable = true
|
|||
export const supportsPessimism = true
|
||||
export const supportsOptimism = false
|
||||
|
||||
export async function getCost ({ id, boost = 0, uploadIds }, { me, models }) {
|
||||
export async function getCost ({ id, boost = 0, uploadIds, bio }, { me, models }) {
|
||||
// the only reason updating items costs anything is when it has new uploads
|
||||
// or more boost
|
||||
const old = await models.item.findUnique({ where: { id: parseInt(id) } })
|
||||
|
@ -19,7 +19,7 @@ export async function getCost ({ id, boost = 0, uploadIds }, { me, models }) {
|
|||
throw new Error('creation invoice not paid')
|
||||
}
|
||||
|
||||
return cost
|
||||
return bio ? BigInt(0) : cost
|
||||
}
|
||||
|
||||
export async function perform (args, context) {
|
||||
|
|
|
@ -691,7 +691,7 @@ export default {
|
|||
|
||||
return Number(photoId)
|
||||
},
|
||||
upsertBio: async (parent, { bio }, { me, models }) => {
|
||||
upsertBio: async (parent, { bio }, { me, models, lnd }) => {
|
||||
if (!me) {
|
||||
throw new GqlAuthenticationError()
|
||||
}
|
||||
|
@ -701,9 +701,9 @@ export default {
|
|||
const user = await models.user.findUnique({ where: { id: me.id } })
|
||||
|
||||
if (user.bioId) {
|
||||
await updateItem(parent, { id: user.bioId, text: bio, title: `@${user.name}'s bio` }, { me, models })
|
||||
await updateItem(parent, { id: user.bioId, text: bio, title: `@${user.name}'s bio` }, { me, models, lnd })
|
||||
} else {
|
||||
await createItem(parent, { bio: true, text: bio, title: `@${user.name}'s bio` }, { me, models })
|
||||
await createItem(parent, { bio: true, text: bio, title: `@${user.name}'s bio` }, { me, models, lnd })
|
||||
}
|
||||
|
||||
return await models.user.findUnique({ where: { id: me.id } })
|
||||
|
|
|
@ -37,7 +37,7 @@ export default function ItemInfo ({
|
|||
const editThreshold = new Date(item.invoice?.confirmedAt ?? item.createdAt).getTime() + 10 * 60000
|
||||
const { me } = useMe()
|
||||
const router = useRouter()
|
||||
const [canEdit, setCanEdit] = useState(item.mine && (Date.now() < editThreshold))
|
||||
const [canEdit, setCanEdit] = useState(item.mine && !item.bio && (Date.now() < editThreshold))
|
||||
const [hasNewComments, setHasNewComments] = useState(false)
|
||||
const root = useRoot()
|
||||
const sub = item?.sub || root?.sub
|
||||
|
@ -49,7 +49,7 @@ export default function ItemInfo ({
|
|||
}, [item])
|
||||
|
||||
useEffect(() => {
|
||||
const authorEdit = item.mine
|
||||
const authorEdit = item.mine && !item.bio
|
||||
const invParams = window.localStorage.getItem(`item:${item.id}:hash:hmac`)
|
||||
const hmacEdit = !!invParams && !me && Number(item.user.id) === USER_ID.anon
|
||||
setCanEdit((authorEdit || hmacEdit) && (Date.now() < editThreshold))
|
||||
|
|
Loading…
Reference in New Issue