@devrongx/games 0.4.9 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -144,10 +144,9 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
144
144
|
}
|
|
145
145
|
const answeredCount = Object.keys(restored).length;
|
|
146
146
|
if (answeredCount === 0) return;
|
|
147
|
-
const allAnswered = answeredCount === config.markets.length;
|
|
148
147
|
setBets(restored);
|
|
149
|
-
if (
|
|
150
|
-
//
|
|
148
|
+
if (answeredCount >= 5) {
|
|
149
|
+
// 5+ questions answered — skip straight to game screen
|
|
151
150
|
setUserFlowState("game");
|
|
152
151
|
} else {
|
|
153
152
|
// Partial — restore into questions at the first unanswered question
|
|
@@ -158,35 +157,7 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
158
157
|
draftRestoredRef.current = true;
|
|
159
158
|
}, [poolId, config, entryData]);
|
|
160
159
|
|
|
161
|
-
// ── Debounced draft save: persists bets to backend 1s after last change ───
|
|
162
160
|
const saveDraftTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (!poolId || Object.keys(bets).length === 0 || !config) return;
|
|
165
|
-
if (saveDraftTimerRef.current) clearTimeout(saveDraftTimerRef.current);
|
|
166
|
-
saveDraftTimerRef.current = setTimeout(async () => {
|
|
167
|
-
try {
|
|
168
|
-
const selections = config.markets
|
|
169
|
-
.map((m, mIdx) => {
|
|
170
|
-
const b = bets[mIdx];
|
|
171
|
-
if (!b || !m.backendChallengeId) return null;
|
|
172
|
-
const option = m.options[b.optionIdx];
|
|
173
|
-
if (!option) return null;
|
|
174
|
-
return {
|
|
175
|
-
challenge_id: m.backendChallengeId,
|
|
176
|
-
selected_option: option.label.toLowerCase().replace(/\s+/g, "_"),
|
|
177
|
-
coin_amount: b.amount,
|
|
178
|
-
};
|
|
179
|
-
})
|
|
180
|
-
.filter((b): b is NonNullable<typeof b> => b !== null);
|
|
181
|
-
if (selections.length > 0) {
|
|
182
|
-
await saveTDDraftBetsApi(poolId, selections);
|
|
183
|
-
}
|
|
184
|
-
} catch {
|
|
185
|
-
// Silent — draft save is best-effort
|
|
186
|
-
}
|
|
187
|
-
}, 1000);
|
|
188
|
-
return () => { if (saveDraftTimerRef.current) clearTimeout(saveDraftTimerRef.current); };
|
|
189
|
-
}, [bets, poolId, config]);
|
|
190
161
|
|
|
191
162
|
// Debounced save triggered from PreMatchQuestions on each option pick
|
|
192
163
|
const handleQuestionSelectionChange = useCallback((selections: IUserBets) => {
|