Skip to content

Commit c8ca330

Browse files
committed
Address ad review simplifications
1 parent c3ee285 commit c8ca330

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

cli/src/hooks/use-gravity-ad.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ export const useGravityAd = (options?: {
180180
})
181181
}
182182

183-
// Show a choice ad set (impressions are fired by the component for visible ads only)
184-
const showChoiceAds = (ads: AdResponse[]): void => {
185-
setAds(ads)
186-
}
187-
188183
type FetchAdResult = { ads: AdResponse[] } | null
189184

190185
// Fetch an ad via web API
@@ -303,13 +298,13 @@ export const useGravityAd = (options?: {
303298
if (result) {
304299
addToChoiceCache(ctrl, result.ads)
305300
ctrl.adsShownSinceActivity += 1
306-
showChoiceAds(result.ads)
301+
setAds(result.ads)
307302
} else {
308303
// Fall back to cached ads
309304
const cachedSet = nextFromChoiceCache(ctrl)
310305
if (cachedSet) {
311306
ctrl.adsShownSinceActivity += 1
312-
showChoiceAds(cachedSet)
307+
setAds(cachedSet)
313308
}
314309
}
315310
} finally {
@@ -338,7 +333,7 @@ export const useGravityAd = (options?: {
338333
if (result) {
339334
const ctrl = ctrlRef.current
340335
addToChoiceCache(ctrl, result.ads)
341-
showChoiceAds(result.ads)
336+
setAds(result.ads)
342337
ctrl.adsShownSinceActivity = 1
343338
}
344339
setIsLoading(false)

web/src/app/api/v1/ads/_post.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ export type AdsEnv = {
5454
}
5555

5656
function noAdsResponse(provider: AdProviderId) {
57-
return NextResponse.json(
58-
{ ads: [], variant: 'choice', provider },
59-
{ status: 200 },
60-
)
57+
return NextResponse.json({ ads: [], provider }, { status: 200 })
6158
}
6259

6360
export async function postAds(params: {
@@ -202,12 +199,11 @@ export async function postAds(params: {
202199
}
203200

204201
logger.info(
205-
{ provider: provider.id, variant: 'choice', adCount: result.ads.length },
206-
'[ads] Fetched choice ads',
202+
{ provider: provider.id, adCount: result.ads.length },
203+
'[ads] Fetched ads',
207204
)
208205
return NextResponse.json({
209206
ads: result.ads.map(toClient),
210-
variant: 'choice',
211207
provider: provider.id,
212208
})
213209
} catch (error) {
@@ -225,7 +221,6 @@ export async function postAds(params: {
225221
return NextResponse.json(
226222
{
227223
ads: [],
228-
variant: 'choice',
229224
provider: providerId,
230225
error: getErrorObject(error),
231226
},

0 commit comments

Comments
 (0)