Skip to content

Commit

Permalink
fix: real time survey bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
avp1598 committed Apr 3, 2023
1 parent 6293466 commit 0aab4d9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ const CollectERC20 = ({ form, setClaimedJustNow, preview }: Props) => {
useEffect(() => {
if (socket)
socket?.on(
`${form.id}:responseAddedOnChain`,
`${form.slug}:responseAddedOnChain`,
_.debounce(async (event: { userAddress: string }) => {
console.log({ event });
if (event.userAddress === address) {
if (event.userAddress.toLowerCase() === address?.toLowerCase()) {
setCanClaimSurveyToken(true);
}
}, 2000)
);
return () => {
if (socket && socket.off) {
socket.off(`${form.id}:responseAddedOnChain`);
socket.off(`${form.slug}:responseAddedOnChain`);
}
};
}, [socket]);
Expand Down Expand Up @@ -330,7 +330,7 @@ const CollectERC20 = ({ form, setClaimedJustNow, preview }: Props) => {
{" "}
<PrimaryButton
loading={claiming}
disabled={canClaimSurveyToken ? false : true}
disabled={!canClaimSurveyToken}
onClick={async () => {
setClaiming(true);
try {
Expand Down

0 comments on commit 0aab4d9

Please sign in to comment.