From 1adfdb4a15dfbfb4d6086007c01c65c33b4b3c88 Mon Sep 17 00:00:00 2001 From: vineyardbovines Date: Tue, 12 May 2026 14:31:39 -0400 Subject: [PATCH] [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. --- .../PublicationEmbed/MetaRow.tsx | 2 +- .../PublicationEmbed/PublicationFooter.tsx | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/MetaRow.tsx b/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/MetaRow.tsx index 8c7330aaf2..b3ccc5a8b5 100644 --- a/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/MetaRow.tsx +++ b/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/MetaRow.tsx @@ -44,7 +44,7 @@ export function MetaRow({link}: {link: PublicationViewExternal}) { the URL). Component exists below for the moment that field lands. */} {/* */} - {typeof link.readingTime === 'number' && ( + {typeof link.readingTime === 'number' && link.readingTime > 0 && ( )} diff --git a/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/PublicationFooter.tsx b/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/PublicationFooter.tsx index 4ccbfada04..ad4ce1bf56 100644 --- a/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/PublicationFooter.tsx +++ b/src/components/Post/Embed/ExternalEmbed/PublicationEmbed/PublicationFooter.tsx @@ -1,3 +1,4 @@ +import {useEffect} from 'react' import {View} from 'react-native' import {Trans, useLingui} from '@lingui/react/macro' @@ -21,15 +22,17 @@ export function PublicationFooter({ const did = parseDidFromAtUri(source.associatedRecord?.uri) const profileQuery = useProfileQuery({did: did ?? undefined}) - if (profileQuery.error && did) { - // Sweep finding: silence non-actionable network errors here. We use - // `logger.error` only when the DID was present and the lookup failed for - // a non-network reason; React Query already handles transient network - // failures with its built-in retry. This keeps Sentry quiet on broken DIDs. - logger.error('PublicationEmbed handle resolve failed', { - safeMessage: profileQuery.error, - }) - } + const profileError = profileQuery.error + useEffect(() => { + if (profileError && did) { + // Log once per error transition. React Query handles transient network + // failures via retry; once the error is set we don't want to re-log on + // every render (could burn Sentry quota with a feed of broken DIDs). + logger.error('PublicationEmbed handle resolve failed', { + safeMessage: profileError, + }) + } + }, [profileError, did]) const handle = did ? profileQuery.data?.handle : undefined const name = source.name || (source.uri ? toNiceDomain(source.uri) : '')