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:
c0mrade
2026-02-04 16:09:10 +03:00
parent 59a251cb8c
commit 4499c9ad57

View File

@@ -72,6 +72,7 @@ export default function Wheel() {
);
const [isPayingStars, setIsPayingStars] = useState(false);
const [historyExpanded, setHistoryExpanded] = useState(false);
const paymentTypeInitialized = useRef(false);
// Check if we're in Telegram Mini App environment
const isTelegramMiniApp = platform === 'telegram';
@@ -90,9 +91,10 @@ export default function Wheel() {
queryFn: () => wheelApi.getHistory(1, 10),
});
// Auto-select payment type based on availability
// Auto-select payment type based on availability (only on initial load)
useEffect(() => {
if (!config) return;
if (!config || paymentTypeInitialized.current) return;
paymentTypeInitialized.current = true;
const starsEnabled = config.spin_cost_stars_enabled && config.spin_cost_stars;
const daysEnabled = config.spin_cost_days_enabled && config.spin_cost_days;