mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-26 17:52:18 +01:00
small fix for vote buttons
This commit is contained in:
parent
99d1115304
commit
b6129e2cf3
@ -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",
|
||||
|
@ -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={<ChevronUpIcon boxSize={6} />}
|
||||
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) && <Text my="1">{vote}</Text>}
|
||||
<IconButton
|
||||
@ -67,10 +68,10 @@ export default function PostVoteButtons({ event, community }: { event: NostrEven
|
||||
title="down vote"
|
||||
icon={<ChevronDownIcon boxSize={6} />}
|
||||
size="sm"
|
||||
variant={myVote?.content === "-" ? "solid" : "ghost"}
|
||||
variant={hasDownVote ? "solid" : "ghost"}
|
||||
isLoading={loading}
|
||||
onClick={() => addVote("-")}
|
||||
isDisabled={!account || !!myVote}
|
||||
isDisabled={!account || !!hasUpVote}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
|
12
yarn.lock
12
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==
|
||||
|
Loading…
x
Reference in New Issue
Block a user