11import type { ReactElement } from 'react' ;
22import React from 'react' ;
3- import { useQueryClient } from '@tanstack/react-query' ;
43import type { AdSquadItem , FeedItem } from '../hooks/useFeed' ;
54import { isBoostedPostAd , isBoostedSquadAd } from '../hooks/useFeed' ;
65import { PlaceholderGrid } from './cards/placeholder/PlaceholderGrid' ;
@@ -56,13 +55,7 @@ import { OtherFeedPage } from '../lib/query';
5655import { isSourceSquadOrMachine } from '../graphql/sources' ;
5756import { HighlightGrid } from './cards/highlight/HighlightGrid' ;
5857import { HighlightList } from './cards/highlight/HighlightList' ;
59- import {
60- getHighlightIdsKey ,
61- getHighlightIds ,
62- MAJOR_HEADLINES_MAX_FIRST ,
63- majorHeadlinesQueryOptions ,
64- } from '../graphql/highlights' ;
65- import { HighlightPostModal } from './modals/HighlightPostModal' ;
58+ import { getHighlightIds , getHighlightIdsKey } from '../graphql/highlights' ;
6659
6760export type FeedItemComponentProps = {
6861 item : FeedItem ;
@@ -271,10 +264,6 @@ function FeedItemComponent({
271264 disableAdRefresh,
272265} : FeedItemComponentProps ) : ReactElement | null {
273266 const { logEvent } = useLogContext ( ) ;
274- const queryClient = useQueryClient ( ) ;
275- const [ selectedHighlightId , setSelectedHighlightId ] = React . useState <
276- string | null
277- > ( null ) ;
278267 const inViewRef = useLogImpression (
279268 item ,
280269 index ,
@@ -294,90 +283,44 @@ function FeedItemComponent({
294283 ? HighlightList
295284 : HighlightGrid ;
296285 const highlightIds = getHighlightIds ( item . highlights ) ;
297- const openHighlightModal = ( highlightId : string ) : void => {
298- queryClient
299- . fetchQuery (
300- majorHeadlinesQueryOptions ( { first : MAJOR_HEADLINES_MAX_FIRST } ) ,
301- )
302- . catch ( ( ) => undefined )
303- . finally ( ( ) => setSelectedHighlightId ( highlightId ) ) ;
304- } ;
305286
306287 return (
307- < >
308- < HighlightTag
309- ref = { inViewRef }
310- highlights = { item . highlights }
311- onReadAllClick = { ( ) => {
312- const [ firstHighlight ] = item . highlights ;
313-
314- if ( ! firstHighlight ) {
315- return ;
316- }
317-
318- logEvent (
319- feedHighlightsLogEvent ( LogEvent . Click , {
320- columns : virtualizedNumCards ,
321- column,
322- row,
323- feedName,
324- ranking,
325- action : 'read_all_click' ,
326- count : item . highlights . length ,
327- highlightIds,
328- feedMeta : item . feedMeta ,
329- } ) ,
330- ) ;
331-
332- openHighlightModal ( firstHighlight . id ) ;
333- } }
334- onHighlightClick = { ( highlight , position ) => {
335- logEvent (
336- feedHighlightsLogEvent ( LogEvent . Click , {
337- columns : virtualizedNumCards ,
338- column,
339- row,
340- feedName,
341- ranking,
342- action : 'highlight_click' ,
343- position,
344- count : item . highlights . length ,
345- clickedHighlight : highlight ,
346- highlightIds,
347- feedMeta : item . feedMeta ,
348- } ) ,
349- ) ;
350-
351- openHighlightModal ( highlight . id ) ;
352- } }
353- />
354- < HighlightPostModal
355- isOpen = { ! ! selectedHighlightId }
356- selectedHighlightId = { selectedHighlightId }
357- highlights = { item . highlights }
358- onRequestClose = { ( ) => setSelectedHighlightId ( null ) }
359- onHighlightClick = { ( highlight , position , modalHighlights ) => {
360- logEvent (
361- feedHighlightsLogEvent ( LogEvent . Click , {
362- columns : virtualizedNumCards ,
363- column,
364- row,
365- feedName,
366- ranking,
367- action : 'modal_highlight_click' ,
368- position,
369- count : modalHighlights . length ,
370- clickedHighlight : highlight ,
371- highlightIds : getHighlightIds ( modalHighlights ) ,
372- feedMeta : item . feedMeta ,
373- } ) ,
374- ) ;
375- } }
376- onSelectHighlight = { ( highlight ) => {
377- setSelectedHighlightId ( highlight . id ) ;
378- } }
379- />
380- </ >
288+ < HighlightTag
289+ ref = { inViewRef }
290+ highlights = { item . highlights }
291+ onReadAllClick = { ( ) => {
292+ logEvent (
293+ feedHighlightsLogEvent ( LogEvent . Click , {
294+ columns : virtualizedNumCards ,
295+ column,
296+ row,
297+ feedName,
298+ ranking,
299+ action : 'read_all_click' ,
300+ count : item . highlights . length ,
301+ highlightIds,
302+ feedMeta : item . feedMeta ,
303+ } ) ,
304+ ) ;
305+ } }
306+ onHighlightClick = { ( highlight , position ) => {
307+ logEvent (
308+ feedHighlightsLogEvent ( LogEvent . Click , {
309+ columns : virtualizedNumCards ,
310+ column,
311+ row,
312+ feedName,
313+ ranking,
314+ action : 'highlight_click' ,
315+ position,
316+ count : item . highlights . length ,
317+ clickedHighlight : highlight ,
318+ highlightIds,
319+ feedMeta : item . feedMeta ,
320+ } ) ,
321+ ) ;
322+ } }
323+ />
381324 ) ;
382325 }
383326
0 commit comments