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 }, boost: { gte: boost },
status: 'ACTIVE', status: 'ACTIVE',
deletedAt: null, deletedAt: null,
outlawed: false outlawed: false,
parentId: null
} }
if (id) { if (id) {
where.id = { not: Number(id) } where.id = { not: Number(id) }
@ -698,7 +699,7 @@ export default {
return { return {
home: await models.item.count({ where }) === 0, 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 [boost, setBoost] = useState(Number(item?.boost) + (act ? BOOST_MULT : 0))
const [getBoostPosition, { data }] = useLazyQuery(gql` const [getBoostPosition, { data }] = useLazyQuery(gql`
query BoostPosition($id: ID, $boost: Int) { query BoostPosition($sub: String, $id: ID, $boost: Int) {
boostPosition(sub: "${item?.subName || sub?.name}", id: $id, boost: $boost) { boostPosition(sub: $sub, id: $id, boost: $boost) {
home home
sub sub
} }
@ -101,10 +101,10 @@ export function BoostItemInput ({ item, sub, act = false, ...props }) {
const getPositionDebounce = useDebounceCallback((...args) => getBoostPosition(...args), 1000, [getBoostPosition]) const getPositionDebounce = useDebounceCallback((...args) => getBoostPosition(...args), 1000, [getBoostPosition])
useEffect(() => { useEffect(() => {
if (boost) { if (boost >= 0 && !item?.parentId) {
getPositionDebounce({ variables: { boost: Number(boost), id: item?.id } }) 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(() => { const boostMessage = useMemo(() => {
if (!item?.parentId) { if (!item?.parentId) {