From 956f5ee16058227af4ebbbac180361b9fe4326e8 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 19:22:52 +0000 Subject: [PATCH] fix(companion): persist region in extension and fix iOS delete account link Addresses two Devin Review findings on #80: - Extension background now persists the region received from the companion iframe (`cal_region` in `storage.local`) before validating tokens, so `getApiBaseUrl()` / `validateTokens` / `fetchEventTypes` etc. hit the correct regional endpoint for EU users instead of always defaulting to `api.cal.com`. - iOS More page "Delete Account" link now uses `getCalAppUrl()` to match the rest of the file and the Android/web counterpart. Co-Authored-By: peer@cal.com --- apps/extension/entrypoints/background/index.ts | 9 ++++++++- apps/mobile/app/(tabs)/(more)/index.ios.tsx | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/extension/entrypoints/background/index.ts b/apps/extension/entrypoints/background/index.ts index dec4455..cda55da 100644 --- a/apps/extension/entrypoints/background/index.ts +++ b/apps/extension/entrypoints/background/index.ts @@ -405,6 +405,7 @@ export default defineBackground(() => { if (message.action === "sync-oauth-tokens") { const tokens = message.tokens as OAuthTokens | null; + const region: "us" | "eu" = message.region === "eu" ? "eu" : "us"; if (isRateLimited()) { devLog.warn("Token sync rate limited"); @@ -417,7 +418,13 @@ export default defineBackground(() => { return true; } - validateTokens(tokens) + const persistRegion = new Promise((resolve) => { + if (!storageAPI?.local) return resolve(); + storageAPI.local.set({ [REGION_STORAGE_KEY]: region }, () => resolve()); + }); + + persistRegion + .then(() => validateTokens(tokens)) .then((isValid) => { if (!isValid) { devLog.warn("Token sync rejected: invalid tokens"); diff --git a/apps/mobile/app/(tabs)/(more)/index.ios.tsx b/apps/mobile/app/(tabs)/(more)/index.ios.tsx index 71da31b..1e743c4 100644 --- a/apps/mobile/app/(tabs)/(more)/index.ios.tsx +++ b/apps/mobile/app/(tabs)/(more)/index.ios.tsx @@ -278,7 +278,7 @@ export default function More() { > - openInAppBrowser("https://app.cal.com/settings/my-account/profile", "Delete Account") + openInAppBrowser(`${getCalAppUrl()}/settings/my-account/profile`, "Delete Account") } style={{ flexDirection: "row",