11// React
2- import React , { useContext } from 'react' ;
2+ import React , { useContext , useRef } from 'react' ;
33
44// Navigation
55import { useNavigate } from 'react-router-dom' ;
@@ -30,7 +30,8 @@ export default function AdvisoriesList(props) {
3030 const navigate = useNavigate ( ) ;
3131
3232 // Props
33- const { advisories, showDescription, showTimestamp, showPublished, isAdvisoriesListPage, showLoader } = props ;
33+ const { advisories, showDescription, showTimestamp, showPublished, isAdvisoriesListPage, showLoader, trackedAdvisories = { } , advisoryRefs } = props ;
34+ const { dismissHighlight } = props ;
3435
3536 function handleClick ( advisory , keyEvent ) {
3637 // Ignore key presses that aren't enter or space
@@ -39,6 +40,12 @@ export default function AdvisoriesList(props) {
3940 }
4041
4142 trackEvent ( 'click' , 'advisories-list' , 'Advisory' , advisory . title , advisory . teaser ) ;
43+ // dismissedHighlightsRef.current.add(advisory.id);
44+ // sessionStorage.setItem(
45+ // 'dismissedHighlights',
46+ // JSON.stringify([...dismissedHighlightsRef.current])
47+ // );
48+ dismissHighlight ( advisory . id ) ; // use parent's function
4249 navigate ( `/advisories/${ advisory . slug } ` ) ;
4350 }
4451
@@ -50,7 +57,12 @@ export default function AdvisoriesList(props) {
5057 { ! ! sortedAdvisories && sortedAdvisories . map ( ( advisory , index ) => {
5158 if ( isAdvisoriesListPage ) {
5259 return (
53- < div className = "advisory-li" key = { advisory . id } >
60+ < div
61+ className = { `advisory-li${ trackedAdvisories [ advisory . id ] ?. highlight ? ' highlighted' : '' } ` }
62+ key = { advisory . id }
63+ data-key = { advisory . id }
64+ ref = { ( el ) => { if ( advisoryRefs ) advisoryRefs . current [ advisory . id ] = el ; } }
65+ >
5466 < div className = "advisory-li__content" >
5567 < div className = "advisory-li__content__partition advisory-li-title-container" >
5668 < div className = "advisory-li-title link-div"
@@ -67,6 +79,9 @@ export default function AdvisoriesList(props) {
6779 < div className = "timestamp-container" >
6880 < span className = "advisory-li-state" > { advisory . first_published_at != advisory . last_published_at ? "Updated" : "Published" } </ span >
6981 < FriendlyTime date = { advisory . latest_revision_created_at } />
82+ { trackedAdvisories [ advisory . id ] ?. highlight &&
83+ < div className = "updated-pill" > Updated</ div >
84+ }
7085 </ div >
7186 }
7287 </ div >
@@ -97,6 +112,9 @@ export default function AdvisoriesList(props) {
97112 < div className = "advisory-li__content__partition timestamp-container timestamp-container--mobile" >
98113 < span className = "advisory-li-state" > { advisory . first_published_at != advisory . last_published_at ? "Updated" : "Published" } </ span >
99114 < FriendlyTime date = { advisory . latest_revision_created_at } />
115+ { trackedAdvisories [ advisory . id ] ?. highlight &&
116+ < div className = "updated-pill" > Updated</ div >
117+ }
100118 </ div >
101119 }
102120
@@ -141,6 +159,9 @@ export default function AdvisoriesList(props) {
141159 { ! cmsContext . readAdvisories . includes ( advisory . id . toString ( ) + '-' + advisory . live_revision . toString ( ) ) && < div className = "unread-display" > </ div > }
142160 < span className = "advisory-li-state" > { advisory . first_published_at != advisory . last_published_at ? "Updated" : "Published" } </ span >
143161 < FriendlyTime date = { advisory . latest_revision_created_at } />
162+ { trackedAdvisories [ advisory . id ] ?. highlight &&
163+ < div className = "updated-pill" > Updated</ div >
164+ }
144165 </ div >
145166 }
146167
@@ -166,6 +187,9 @@ export default function AdvisoriesList(props) {
166187 < div className = "timestamp-container timestamp-container--mobile" >
167188 < span className = "advisory-li-state" > { advisory . first_published_at != advisory . last_published_at ? "Updated" : "Published" } </ span >
168189 < FriendlyTime date = { advisory . latest_revision_created_at } />
190+ { trackedAdvisories [ advisory . id ] ?. highlight &&
191+ < div className = "updated-pill" > Updated</ div >
192+ }
169193 </ div >
170194 }
171195 </ div >
0 commit comments