fix: defer HeroSMS reuse confirmation until final cleanup

This commit is contained in:
zhangkun
2026-04-28 21:49:58 +08:00
parent 59663c4ca3
commit b8d8847ce5
5 changed files with 89 additions and 7 deletions
+1 -1
View File
@@ -203,10 +203,10 @@
excludeLocalhostCallbacks: true,
});
}
await finalizeIcloudAliasAfterSuccessfulFlow(latestState);
if (typeof finalizePhoneActivationAfterSuccessfulFlow === 'function') {
await finalizePhoneActivationAfterSuccessfulFlow(latestState);
}
await finalizeIcloudAliasAfterSuccessfulFlow(latestState);
}
async function handleStepData(step, payload) {
+5 -4
View File
@@ -248,18 +248,19 @@
}
}
function resolvePhoneConfig(state = {}) {
function resolvePhoneConfig(state = {}, options = {}) {
const apiKey = normalizeApiKey(state.heroSmsApiKey);
if (!apiKey) {
throw new Error('HeroSMS API key is missing. Save it in the side panel before running the phone flow.');
}
const requireMaxPrice = Boolean(options.requireMaxPrice);
const maxPrice = normalizeManualHeroSmsMaxPrice(state.heroSmsMaxPrice);
if (!maxPrice) {
if (requireMaxPrice && !maxPrice) {
throw new Error('HeroSMS maxPrice is missing. Fill it in below the country selector before running the phone flow.');
}
return {
apiKey,
maxPrice,
...(maxPrice ? { maxPrice } : {}),
baseUrl: normalizeUrl(state.heroSmsBaseUrl, DEFAULT_HERO_SMS_BASE_URL),
};
}
@@ -324,7 +325,7 @@
}
async function requestPhoneActivation(state = {}) {
const config = resolvePhoneConfig(state);
const config = resolvePhoneConfig(state, { requireMaxPrice: true });
const countryConfig = resolveCountryConfig(state);
const maxPrice = config.maxPrice;
const buildFallbackActivation = (requestAction) => ({