ek boost hint suggestions

This commit is contained in:
k00b 2024-09-19 15:27:09 -05:00
parent 09be42844e
commit 2f191e04f9
2 changed files with 8 additions and 7 deletions

View File

@ -690,7 +690,8 @@ export default {
boost: { gte: boost },
status: 'ACTIVE',
deletedAt: null,
outlawed: false
outlawed: false,
parentId: null
}
if (id) {
where.id = { not: Number(id) }
@ -698,7 +699,7 @@ export default {
return {
home: await models.item.count({ where }) === 0,
sub: await models.item.count({ where: { ...where, subName: sub } }) === 0
sub: sub ? await models.item.count({ where: { ...where, subName: sub } }) === 0 : false
}
}
},

View File

@ -90,8 +90,8 @@ export function BoostItemInput ({ item, sub, act = false, ...props }) {
const [boost, setBoost] = useState(Number(item?.boost) + (act ? BOOST_MULT : 0))
const [getBoostPosition, { data }] = useLazyQuery(gql`
query BoostPosition($id: ID, $boost: Int) {
boostPosition(sub: "${item?.subName || sub?.name}", id: $id, boost: $boost) {
query BoostPosition($sub: String, $id: ID, $boost: Int) {
boostPosition(sub: $sub, id: $id, boost: $boost) {
home
sub
}
@ -101,10 +101,10 @@ export function BoostItemInput ({ item, sub, act = false, ...props }) {
const getPositionDebounce = useDebounceCallback((...args) => getBoostPosition(...args), 1000, [getBoostPosition])
useEffect(() => {
if (boost) {
getPositionDebounce({ variables: { boost: Number(boost), id: item?.id } })
if (boost >= 0 && !item?.parentId) {
getPositionDebounce({ variables: { sub: item?.subName || sub?.name, boost: Number(boost), id: item?.id } })
}
}, [boost, item?.id])
}, [boost, item?.id, !item?.parentId, item?.subName || sub?.name])
const boostMessage = useMemo(() => {
if (!item?.parentId) {