Skip to content

Commit

Permalink
fix(rakki): Use enabled in useQuery, remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Dec 28, 2024
1 parent a7b0f81 commit a1ada4e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/hooks/rakki/useRakkiTicketsByUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useRakkiTicketsCountByUser = (userId?: string) => {
);
return await client.ticketsCountByUser({ userAddr: userAddress });
},
{ staleTime: Infinity, refetchInterval: 10000 },
{ staleTime: Infinity, refetchInterval: 10000, enabled: !!userId },
);
return { ticketsCount, ...other };
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Long from "long";
import { FC, useEffect, useState } from "react";
import { FC, useState } from "react";
import { View } from "react-native";

import { BrandText } from "@/components/BrandText";
Expand All @@ -16,14 +15,6 @@ export const BuyTicketsButton: FC<{ networkId: string; info: Info }> = ({
}) => {
const [isButtonHovered, setButtonHovered] = useState(false);
const [isModalVisible, setModalVisible] = useState(false);
const remainingTickets = info.config.max_tickets - info.current_tickets_count;
const [ticketAmount, setTicketAmount] = useState("1");
const ticketAmountNumber = Long.fromString(ticketAmount || "0");
useEffect(() => {
if (remainingTickets > 0 && ticketAmountNumber.gt(remainingTickets)) {
setTicketAmount(remainingTickets.toString());
}
}, [ticketAmountNumber, remainingTickets]);

return (
<View style={{ flexDirection: "row" }}>
Expand Down

0 comments on commit a1ada4e

Please sign in to comment.