From b78639bad5c6938861a12f9cd4b6e76155e7406c Mon Sep 17 00:00:00 2001 From: Benjamin Altpeter Date: Fri, 1 Nov 2024 08:51:16 +0100 Subject: [PATCH] Disable iOS for now --- src/lib/app-store/meta.ts | 2 ++ src/lib/app-store/search.ts | 2 ++ src/pages/a/[platform]/[appId]/index.astro | 17 ++++++++++------- src/pages/a/index.astro | 19 +++++++++++-------- src/pages/index.astro | 5 ++--- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/lib/app-store/meta.ts b/src/lib/app-store/meta.ts index cdf6878..cdddf23 100644 --- a/src/lib/app-store/meta.ts +++ b/src/lib/app-store/meta.ts @@ -46,6 +46,8 @@ const fetchAppDetailsIos = pMemoize(throttle('ios', _fetchAppDetailsIos), { }); export const getAppMeta = async (options: GetAppMetaOptions): Promise => { + if (options.platform === 'ios') throw new Error('I cannot let you do that.'); + if (options.platform === 'android') { const res = await fetchAppDetailsAndroid( { appId: options.appId }, diff --git a/src/lib/app-store/search.ts b/src/lib/app-store/search.ts index 77ee093..b2a41ea 100644 --- a/src/lib/app-store/search.ts +++ b/src/lib/app-store/search.ts @@ -39,6 +39,8 @@ const searchAppsIos = pMemoize(throttle('ios', _searchAppsIos), { }); export const searchApps = async (options: SearchAppsOptions): Promise => { + if (options.platform === 'ios') throw new Error('I cannot let you do that.'); + if (options.platform === 'android') { const results = await searchAppsAndroid([{ searchTerm: options.term }], { language: options.language.toLocaleUpperCase() as 'EN', diff --git a/src/pages/a/[platform]/[appId]/index.astro b/src/pages/a/[platform]/[appId]/index.astro index 8dc8e7a..c838570 100644 --- a/src/pages/a/[platform]/[appId]/index.astro +++ b/src/pages/a/[platform]/[appId]/index.astro @@ -7,7 +7,7 @@ import { e, client } from '../../../../lib/db'; const { platform, appId } = Astro.params; if (!platform || !appId) throw new Error('This should never happen.'); -if (platform !== 'android' && platform !== 'ios') return new Response('Invalid platform.', { status: 404 }); +if (platform !== 'android') return new Response('Invalid platform.', { status: 404 }); const analyses = await e .select(e.Analysis, (a) => ({ @@ -21,12 +21,10 @@ const analyses = await e })) .run(client); -if (analyses.length === 0) return new Response('We have not analyzed this app yet.', { status: 404 }); - // An app can theoretically change its name with each new version, we thus use the one we saw in the most recent proceeding. -const name = analyses[0]!.proceeding.appName; +const name = analyses[0]?.proceeding.appName || ''; // On iOS, we need the adamId for getAppMeta(). -const adamId = analyses[0]!.app.adamId; +const adamId = analyses[0]?.app.adamId; --- @@ -42,9 +40,14 @@ const adamId = analyses[0]!.app.adamId; } - + + + diff --git a/src/pages/a/index.astro b/src/pages/a/index.astro index d03b5b5..3187c77 100644 --- a/src/pages/a/index.astro +++ b/src/pages/a/index.astro @@ -7,7 +7,8 @@ import { e, client } from '../../lib/db'; import { ratelimit } from '../../lib/ratelimit'; const term = Astro.url.searchParams.get('q'); -const platform = (Astro.url.searchParams.get('platform') as 'android' | 'ios') || 'android'; +const platform = 'android'; +// const platform = (Astro.url.searchParams.get('platform') as 'android' | 'ios') || 'android'; if (term) await ratelimit({ ip: Astro.clientAddress, action: 'search' }); @@ -69,7 +70,7 @@ const results = - + { @@ -89,12 +91,13 @@ const results = 0 - ? absUrl(`/a/${r.platform}/${r.id}`) - : absUrl( - // Annoyingly, on iOS and only for the getAppMeta() endpoint, we need the adamId instead of the bundleId. - `/p/${r.platform}/${r.platform === 'android' ? r.id : r.adamId}/confirm-platform`, - ) + absUrl(`/a/${r.platform}/${r.id}`) + // r.analysisCount > 0 + // ? absUrl(`/a/${r.platform}/${r.id}`) + // : absUrl( + // // Annoyingly, on iOS and only for the getAppMeta() endpoint, we need the adamId instead of the bundleId. + // `/p/${r.platform}/${r.platform === 'android' ? r.id : r.adamId}/confirm-platform` + // ) }> - - +