Unblock React Compiler for 18 components with value blocks inside try (#11548)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -261,7 +261,10 @@ export function useGetJoinLinkPreview() {
|
||||
staleTime: STALE.SECONDS.FIFTEEN,
|
||||
})
|
||||
const found = data.joinLinkPreviews[0]
|
||||
return isKnownJoinLinkPreview(found) ? found : undefined
|
||||
if (isKnownJoinLinkPreview(found)) {
|
||||
return found
|
||||
}
|
||||
return undefined
|
||||
} catch (error) {
|
||||
logger.error('Failed to fetch join link preview', {safeMessage: error})
|
||||
return undefined
|
||||
|
||||
@@ -13,6 +13,22 @@ type ServiceConfig = {
|
||||
}[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Module scope because React Compiler cannot lower a `??` inside a `try`, and
|
||||
* `data` only exists once the request in that `try` resolves.
|
||||
*/
|
||||
function toServiceConfig(data: {
|
||||
checkEmailConfirmed?: boolean
|
||||
liveNow?: ServiceConfig['liveNow']
|
||||
}): ServiceConfig {
|
||||
return {
|
||||
checkEmailConfirmed: Boolean(data.checkEmailConfirmed),
|
||||
// @ts-expect-error not included in the lexicon atm
|
||||
topicsEnabled: Boolean(data.topicsEnabled),
|
||||
liveNow: data.liveNow ?? [],
|
||||
}
|
||||
}
|
||||
|
||||
export function useServiceConfigQuery() {
|
||||
const client = useAppviewClient()
|
||||
return useQuery<ServiceConfig>({
|
||||
@@ -22,12 +38,7 @@ export function useServiceConfigQuery() {
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const data = await client.call(app.bsky.unspecced.getConfig)
|
||||
return {
|
||||
checkEmailConfirmed: Boolean(data.checkEmailConfirmed),
|
||||
// @ts-expect-error not included in the lexicon atm
|
||||
topicsEnabled: Boolean(data.topicsEnabled),
|
||||
liveNow: data.liveNow ?? [],
|
||||
}
|
||||
return toServiceConfig(data)
|
||||
} catch (e) {
|
||||
return {
|
||||
checkEmailConfirmed: false,
|
||||
|
||||
Reference in New Issue
Block a user