mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
fix: prevent payment type reset after wheel spin
The auto-select useEffect for payment type (days/stars) was running on every config refetch, resetting the user's manual selection back to stars. Now it only runs once on initial load using a ref flag.
This commit is contained in:
@@ -72,6 +72,7 @@ export default function Wheel() {
|
|||||||
);
|
);
|
||||||
const [isPayingStars, setIsPayingStars] = useState(false);
|
const [isPayingStars, setIsPayingStars] = useState(false);
|
||||||
const [historyExpanded, setHistoryExpanded] = useState(false);
|
const [historyExpanded, setHistoryExpanded] = useState(false);
|
||||||
|
const paymentTypeInitialized = useRef(false);
|
||||||
|
|
||||||
// Check if we're in Telegram Mini App environment
|
// Check if we're in Telegram Mini App environment
|
||||||
const isTelegramMiniApp = platform === 'telegram';
|
const isTelegramMiniApp = platform === 'telegram';
|
||||||
@@ -90,9 +91,10 @@ export default function Wheel() {
|
|||||||
queryFn: () => wheelApi.getHistory(1, 10),
|
queryFn: () => wheelApi.getHistory(1, 10),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto-select payment type based on availability
|
// Auto-select payment type based on availability (only on initial load)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!config) return;
|
if (!config || paymentTypeInitialized.current) return;
|
||||||
|
paymentTypeInitialized.current = true;
|
||||||
|
|
||||||
const starsEnabled = config.spin_cost_stars_enabled && config.spin_cost_stars;
|
const starsEnabled = config.spin_cost_stars_enabled && config.spin_cost_stars;
|
||||||
const daysEnabled = config.spin_cost_days_enabled && config.spin_cost_days;
|
const daysEnabled = config.spin_cost_days_enabled && config.spin_cost_days;
|
||||||
|
|||||||
Reference in New Issue
Block a user