@@ -252,29 +252,36 @@ const DDG_MAX_TRACKER_ICONS = 3;
252252function TrackerStatus ( { id, trackersFound } ) {
253253 const { t } = useTypedTranslationWith ( /** @type {enStrings } */ ( { } ) ) ;
254254 const { activity } = useContext ( NormalizedDataContext ) ;
255- const status = useComputed ( ( ) => activity . value . trackingStatus [ id ] ) ;
256- const cookiePopUpBlocked = useComputed ( ( ) => activity . value . cookiePopUpBlocked ?. [ id ] ) . value ;
257255
258- // Provide default if trackingStatus hasn't been populated yet
259- // This handles the case where a site is first logged but trackingStatus hasn't been updated
260- // The component will reactively update when trackingStatus is populated via activity_onDataUpdate
256+ // Use computed to reactively track trackingStatus changes
257+ // This ensures the component updates when trackingStatus is populated via activity_onDataUpdate
261258 // or activity_onDataPatch messages
262- const trackingStatus = status . value || { totalCount : 0 , trackerCompanies : [ ] } ;
263- const totalTrackersBlocked = trackingStatus . totalCount ;
264- const totalTrackersPillText =
265- totalTrackersBlocked === 0
259+ const trackingStatus = useComputed ( ( ) => {
260+ const status = activity . value . trackingStatus [ id ] ;
261+ // Provide default if trackingStatus hasn't been populated yet
262+ // This handles the case where a site is first logged but trackingStatus hasn't been updated
263+ return status || { totalCount : 0 , trackerCompanies : [ ] } ;
264+ } ) ;
265+
266+ // Make text computation reactive so it updates when trackingStatus changes
267+ const totalTrackersBlocked = useComputed ( ( ) => trackingStatus . value . totalCount ) ;
268+ const totalTrackersPillText = useComputed ( ( ) => {
269+ const count = totalTrackersBlocked . value ;
270+ return count === 0
266271 ? trackersFound
267272 ? t ( 'activity_no_trackers_blocked' )
268273 : t ( 'activity_no_trackers' )
269- : t ( totalTrackersBlocked === 1 ? 'activity_countBlockedSingular' : 'activity_countBlockedPlural' , {
270- count : String ( totalTrackersBlocked ) ,
274+ : t ( count === 1 ? 'activity_countBlockedSingular' : 'activity_countBlockedPlural' , {
275+ count : String ( count ) ,
271276 } ) ;
277+ } ) ;
278+ const cookiePopUpBlocked = useComputed ( ( ) => activity . value . cookiePopUpBlocked ?. [ id ] ) ;
272279
273280 return (
274281 < div class = { styles . companiesIconRow } data-testid = "TrackerStatus" >
275282 < div class = { styles . companiesText } >
276- < TickPill text = { totalTrackersPillText } displayTick = { totalTrackersBlocked > 0 } />
277- { cookiePopUpBlocked && < TickPill text = { t ( 'activity_cookiePopUpBlocked' ) } /> }
283+ < TickPill text = { totalTrackersPillText . value } displayTick = { totalTrackersBlocked . value > 0 } />
284+ { cookiePopUpBlocked . value && < TickPill text = { t ( 'activity_cookiePopUpBlocked' ) } /> }
278285 </ div >
279286 </ div >
280287 ) ;
0 commit comments