[APP-2160] Address /grill review: move logger.error to useEffect; guard readingTime > 0
- PublicationFooter: profile-resolve error was logged during render, causing duplicate Sentry events on every re-render of an errored card. Move to useEffect keyed on the error transition. - MetaRow: render reading-time chip only when readingTime > 0. Guards against pathological appview responses where the field is 0 or negative.
This commit is contained in:
committed by
Eric Bailey
parent
c418f7a3df
commit
1adfdb4a15
@@ -44,7 +44,7 @@ export function MetaRow({link}: {link: PublicationViewExternal}) {
|
|||||||
the URL). Component exists below for the moment that field lands.
|
the URL). Component exists below for the moment that field lands.
|
||||||
*/}
|
*/}
|
||||||
{/* <SharesChip count={???} /> */}
|
{/* <SharesChip count={???} /> */}
|
||||||
{typeof link.readingTime === 'number' && (
|
{typeof link.readingTime === 'number' && link.readingTime > 0 && (
|
||||||
<ReadingTimeChip minutes={link.readingTime} />
|
<ReadingTimeChip minutes={link.readingTime} />
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import {useEffect} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
@@ -21,15 +22,17 @@ export function PublicationFooter({
|
|||||||
|
|
||||||
const did = parseDidFromAtUri(source.associatedRecord?.uri)
|
const did = parseDidFromAtUri(source.associatedRecord?.uri)
|
||||||
const profileQuery = useProfileQuery({did: did ?? undefined})
|
const profileQuery = useProfileQuery({did: did ?? undefined})
|
||||||
if (profileQuery.error && did) {
|
const profileError = profileQuery.error
|
||||||
// Sweep finding: silence non-actionable network errors here. We use
|
useEffect(() => {
|
||||||
// `logger.error` only when the DID was present and the lookup failed for
|
if (profileError && did) {
|
||||||
// a non-network reason; React Query already handles transient network
|
// Log once per error transition. React Query handles transient network
|
||||||
// failures with its built-in retry. This keeps Sentry quiet on broken DIDs.
|
// failures via retry; once the error is set we don't want to re-log on
|
||||||
logger.error('PublicationEmbed handle resolve failed', {
|
// every render (could burn Sentry quota with a feed of broken DIDs).
|
||||||
safeMessage: profileQuery.error,
|
logger.error('PublicationEmbed handle resolve failed', {
|
||||||
})
|
safeMessage: profileError,
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
}, [profileError, did])
|
||||||
const handle = did ? profileQuery.data?.handle : undefined
|
const handle = did ? profileQuery.data?.handle : undefined
|
||||||
|
|
||||||
const name = source.name || (source.uri ? toNiceDomain(source.uri) : '')
|
const name = source.name || (source.uri ? toNiceDomain(source.uri) : '')
|
||||||
|
|||||||
Reference in New Issue
Block a user