mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 17:53:29 +00:00
fix(store): specific rate-limit message on tier change + use shared dialogs for subscription flows (#4622)
## Summary - The change-tier API allows one tier change per minute per player (`playerRateLimit` on `/subscriptions/@me/change-tier`). The client previously lumped the 429 in with every other failure and showed "Couldn't update your subscription. Please try again." — retrying immediately just fails again. A 429 now gets its own message: *"You just changed tiers. Please wait a minute before changing again."* - Replaced all native `alert()` / `window.confirm()` calls in the subscription flows with the shared `showInGameAlert` / `showInGameConfirm` helpers (styled `<confirm-dialog>`, consistent with the rest of the store, and safe on CrazyGames): - Tier change: already-subscribed notice, upgrade/downgrade confirmation (warning variant with "Change Tier" heading), rate-limited/failure/success notices - Dollar checkout failures (first-time subscribe path) - Subscription panel: cancel confirmation (danger variant), cancel failure/success, portal-open failure The currency-purchase alerts in Cosmetics.ts (`login_required`, `purchase_failed`, `purchase_success`) are untouched — subscriptions can't reach that path. ## Test plan - [x] Typecheck, ESLint, Prettier - [ ] Manual: change tier twice within a minute against the real API and confirm the rate-limit dialog appears 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -410,7 +410,7 @@ export async function cancelSubscription(): Promise<boolean> {
|
||||
|
||||
export async function changeSubscriptionTier(
|
||||
tierName: string,
|
||||
): Promise<boolean> {
|
||||
): Promise<boolean | "rate_limited"> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${getApiBase()}/subscriptions/@me/change-tier`,
|
||||
@@ -427,6 +427,10 @@ export async function changeSubscriptionTier(
|
||||
await logOut();
|
||||
return false;
|
||||
}
|
||||
// The API allows one tier change per minute per player.
|
||||
if (response.status === 429) {
|
||||
return "rate_limited";
|
||||
}
|
||||
if (!response.ok) {
|
||||
console.error(
|
||||
"changeSubscriptionTier: request failed",
|
||||
|
||||
Reference in New Issue
Block a user