hide zap bolt for forward users (#445)
This commit is contained in:
parent
f1ad321857
commit
88da287a87
|
@ -250,13 +250,14 @@ async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args)
|
||||||
return await models.$queryRawUnsafe(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT "Item".*, to_json(users.*) as user, COALESCE("ItemAct"."meMsats", 0) as "meMsats",
|
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",
|
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 (
|
FROM (
|
||||||
${query}
|
${query}
|
||||||
) "Item"
|
) "Item"
|
||||||
JOIN users ON "Item"."userId" = users.id
|
JOIN users ON "Item"."userId" = users.id
|
||||||
LEFT JOIN "Bookmark" b ON b."itemId" = "Item".id AND b."userId" = ${me.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 "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 (
|
LEFT JOIN LATERAL (
|
||||||
SELECT "itemId", sum("ItemAct".msats) FILTER (WHERE act = 'FEE' OR act = 'TIP') AS "meMsats",
|
SELECT "itemId", sum("ItemAct".msats) FILTER (WHERE act = 'FEE' OR act = 'TIP') AS "meMsats",
|
||||||
bool_or(act = 'DONT_LIKE_THIS') AS "meDontLike"
|
bool_or(act = 'DONT_LIKE_THIS') AS "meDontLike"
|
||||||
|
|
|
@ -91,6 +91,7 @@ export default gql`
|
||||||
meDontLike: Boolean!
|
meDontLike: Boolean!
|
||||||
meBookmark: Boolean!
|
meBookmark: Boolean!
|
||||||
meSubscription: Boolean!
|
meSubscription: Boolean!
|
||||||
|
meForward: Boolean
|
||||||
outlawed: Boolean!
|
outlawed: Boolean!
|
||||||
freebie: Boolean!
|
freebie: Boolean!
|
||||||
paidImgLink: Boolean
|
paidImgLink: Boolean
|
||||||
|
|
|
@ -204,18 +204,8 @@ export default function UpVote ({ item, className, pendingSats, setPendingSats }
|
||||||
}
|
}
|
||||||
}, [pendingSats, act, item, showModal, setPendingSats])
|
}, [pendingSats, act, item, showModal, setPendingSats])
|
||||||
|
|
||||||
const disabled = useMemo(() => {
|
const disabled = useMemo(() => item?.mine || item?.meForward || item?.deletedAt,
|
||||||
if (item?.mine) {
|
[item?.mine, item?.meForward, item?.deletedAt])
|
||||||
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 [meSats, sats, overlayText, color] = useMemo(() => {
|
const [meSats, sats, overlayText, color] = useMemo(() => {
|
||||||
const meSats = (item?.meSats || item?.meAnonSats || 0) + pendingSats
|
const meSats = (item?.meSats || item?.meAnonSats || 0) + pendingSats
|
||||||
|
|
|
@ -28,6 +28,7 @@ export const ITEM_FIELDS = gql`
|
||||||
meDontLike
|
meDontLike
|
||||||
meBookmark
|
meBookmark
|
||||||
meSubscription
|
meSubscription
|
||||||
|
meForward
|
||||||
outlawed
|
outlawed
|
||||||
freebie
|
freebie
|
||||||
ncomments
|
ncomments
|
||||||
|
|
Loading…
Reference in New Issue