From b6129e2cf308e82f25a6200fef2fb648f1a5ceca Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sat, 21 Oct 2023 16:52:21 -0500 Subject: [PATCH] small fix for vote buttons --- package.json | 2 +- .../community/components/post-vote-buttions.tsx | 13 +++++++------ yarn.lock | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 47ac15fa1..22ca30e85 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@chakra-ui/styled-system": "^2.9.1", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", - "@getalby/bitcoin-connect-react": "^1", + "@getalby/bitcoin-connect-react": "1.1.0", "@webscopeio/react-textarea-autocomplete": "^4.9.2", "bech32": "^2.0.0", "cheerio": "^1.0.0-rc.12", diff --git a/src/views/community/components/post-vote-buttions.tsx b/src/views/community/components/post-vote-buttions.tsx index 5efb51aff..e22bbbeb5 100644 --- a/src/views/community/components/post-vote-buttions.tsx +++ b/src/views/community/components/post-vote-buttions.tsx @@ -23,7 +23,8 @@ export default function PostVoteButtons({ event, community }: { event: NostrEven const down = grouped.find((r) => r.emoji === "-"); const vote = (up?.pubkeys.length ?? 0) - (down?.pubkeys.length ?? 0); - const myVote = reactions?.find((e) => e.pubkey === account?.pubkey); + const hasUpVote = !!account && !!up?.pubkeys.includes(account.pubkey); + const hasDownVote = !!account && !!down?.pubkeys.includes(account.pubkey); const { requestSignature } = useSigningContext(); const [loading, setLoading] = useState(false); @@ -55,11 +56,11 @@ export default function PostVoteButtons({ event, community }: { event: NostrEven title="up vote" icon={} size="sm" - variant={myVote?.content === "+" ? "solid" : "ghost"} + variant={hasUpVote ? "solid" : "ghost"} isLoading={loading} onClick={() => addVote("+")} - isDisabled={!account || !!myVote} - colorScheme={myVote ? "primary" : "gray"} + isDisabled={!account || !!hasUpVote} + colorScheme={hasUpVote ? "primary" : "gray"} /> {(up || down) && {vote}} } size="sm" - variant={myVote?.content === "-" ? "solid" : "ghost"} + variant={hasDownVote ? "solid" : "ghost"} isLoading={loading} onClick={() => addVote("-")} - isDisabled={!account || !!myVote} + isDisabled={!account || !!hasUpVote} /> ); diff --git a/yarn.lock b/yarn.lock index 9fe4fc718..6bd5f81cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2235,14 +2235,14 @@ bn.js "^4.11.8" buffer "^6.0.3" -"@getalby/bitcoin-connect-react@^1": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@getalby/bitcoin-connect-react/-/bitcoin-connect-react-1.2.0.tgz#dbbfe516a40ceca5ee8af9966439f0a275e44af1" - integrity sha512-V/iC96GG14PrOsyd/92ZCCyKFJsaxJ7xvnnmzDHxzf2oyrEJcUO8nd7WMfnzQDjSrfv0QWD3qN+9VvDxwEodOw== +"@getalby/bitcoin-connect-react@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@getalby/bitcoin-connect-react/-/bitcoin-connect-react-1.1.0.tgz#d6b97b793b5ae128783e1adafaf7a87f983a6d78" + integrity sha512-oX43GwUffdS2DYCPS7a6hECVWgbw1HZr0zHmR3uX16f7ov9vGjNHj8mSg4aWgYnatrxoNt12gklr1MRf6nYYKg== dependencies: - "@getalby/bitcoin-connect" "^1.2.0" + "@getalby/bitcoin-connect" "^1.1.0" -"@getalby/bitcoin-connect@^1.2.0": +"@getalby/bitcoin-connect@^1.1.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@getalby/bitcoin-connect/-/bitcoin-connect-1.2.0.tgz#d626495a94b5e568bff7c661339bb2b69cd5e8cb" integrity sha512-hIkslzG/SMKFV2NPh9IR/8TyiLsDPWlmtdH6t3MER5+37R/evnLfe3odglBNYb5EVnIPsMprOHR8IqBFyvM1ag==