diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 1cf17a2d..fec0eb7e 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -250,13 +250,14 @@ async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args) return await models.$queryRawUnsafe(` SELECT "Item".*, to_json(users.*) as user, COALESCE("ItemAct"."meMsats", 0) as "meMsats", COALESCE("ItemAct"."meDontLike", false) as "meDontLike", b."itemId" IS NOT NULL AS "meBookmark", - "ThreadSubscription"."itemId" IS NOT NULL AS "meSubscription" + "ThreadSubscription"."itemId" IS NOT NULL AS "meSubscription", "ItemForward"."itemId" IS NOT NULL AS "meForward" FROM ( ${query} ) "Item" JOIN users ON "Item"."userId" = users.id LEFT JOIN "Bookmark" b ON b."itemId" = "Item".id AND b."userId" = ${me.id} LEFT JOIN "ThreadSubscription" ON "ThreadSubscription"."itemId" = "Item".id AND "ThreadSubscription"."userId" = ${me.id} + LEFT JOIN "ItemForward" ON "ItemForward"."itemId" = "Item".id AND "ItemForward"."userId" = ${me.id} LEFT JOIN LATERAL ( SELECT "itemId", sum("ItemAct".msats) FILTER (WHERE act = 'FEE' OR act = 'TIP') AS "meMsats", bool_or(act = 'DONT_LIKE_THIS') AS "meDontLike" diff --git a/api/typeDefs/item.js b/api/typeDefs/item.js index e92c102c..e3c8437b 100644 --- a/api/typeDefs/item.js +++ b/api/typeDefs/item.js @@ -91,6 +91,7 @@ export default gql` meDontLike: Boolean! meBookmark: Boolean! meSubscription: Boolean! + meForward: Boolean outlawed: Boolean! freebie: Boolean! paidImgLink: Boolean diff --git a/components/upvote.js b/components/upvote.js index 4a5a5847..ff2665f6 100644 --- a/components/upvote.js +++ b/components/upvote.js @@ -204,18 +204,8 @@ export default function UpVote ({ item, className, pendingSats, setPendingSats } } }, [pendingSats, act, item, showModal, setPendingSats]) - const disabled = useMemo(() => { - if (item?.mine) { - return true - } - if (me && item?.forwards?.some?.(fwd => Number(fwd.userId) === Number(me?.id))) { - return true - } - if (item?.deletedAt) { - return true - } - return false - }, [me?.id, item?.forwards, item?.mine, item?.deletedAt]) + const disabled = useMemo(() => item?.mine || item?.meForward || item?.deletedAt, + [item?.mine, item?.meForward, item?.deletedAt]) const [meSats, sats, overlayText, color] = useMemo(() => { const meSats = (item?.meSats || item?.meAnonSats || 0) + pendingSats diff --git a/fragments/items.js b/fragments/items.js index 685838e5..383cbdce 100644 --- a/fragments/items.js +++ b/fragments/items.js @@ -28,6 +28,7 @@ export const ITEM_FIELDS = gql` meDontLike meBookmark meSubscription + meForward outlawed freebie ncomments