1- import React , { useEffect , useMemo , useRef } from 'react' ;
1+ import React , { useEffect , useRef } from 'react' ;
22import PropTypes from 'prop-types' ;
33import {
44 defineMessages ,
@@ -34,7 +34,7 @@ const propTypes = {
3434} ;
3535
3636const defaultProps = {
37- handleSearch : ( ) => { } ,
37+ handleSearch : ( ) => { } ,
3838 interactive : false ,
3939 search : [ ] ,
4040} ;
@@ -44,6 +44,7 @@ const Thumbnails = ({
4444 interactive,
4545 search,
4646} ) => {
47+ const currentIndex = useCurrentIndex ( storage . thumbnails ) ;
4748 const interaction = useRef ( false ) ;
4849 const firstNode = useRef ( ) ;
4950 const currentNode = useRef ( ) ;
@@ -76,52 +77,6 @@ const Thumbnails = ({
7677 }
7778 } ) ;
7879
79- const items = useMemo ( ( ) => {
80- const thumbnails = storage . thumbnails ;
81- const layoutSwap = storage . layoutSwap ?? [ ] ;
82- const merged = [ ...thumbnails , ...layoutSwap ] ;
83- const sorted = merged . sort ( ( a , b ) => a . timestamp - b . timestamp ) ;
84-
85- const addThumbsForSwap = sorted . map ( ( item , index , arr ) => {
86- const previousItem = arr [ index - 1 ] ;
87- const nextItem = arr [ index + 1 ] ;
88- if ( item . hasOwnProperty ( 'showScreenshare' ) ) {
89- if ( ! item . showScreenshare ) {
90- const previousThumbs = arr . slice ( 0 , index )
91- const Thumbnail = previousThumbs . find ( ( t ) => t . src && t . src !== 'screenshare' ) ;
92- return {
93- ...item ,
94- src : Thumbnail ?. src ?? '' ,
95- alt : Thumbnail ?. alt ?? '' ,
96- } ;
97- } else if (
98- item . showScreenshare
99- && ( nextItem && nextItem . src !== 'screenshare' )
100- && ( previousItem && previousItem . src !== 'screenshare' )
101- ) {
102- return {
103- ...item ,
104- src : 'screenshare' ,
105- alt : 'screenshare' ,
106- }
107- }
108- return null ;
109- }
110- return item ;
111- } ) . filter ( ( item ) => item !== null ) ;
112-
113- const reworkIds = addThumbsForSwap . map ( ( item , index ) => {
114- return {
115- ...item ,
116- id : index + 1 ,
117- }
118- } ) ;
119-
120- return reworkIds ;
121- } , [ storage . thumbnails , storage . layoutSwap ] ) ;
122-
123- const currentIndex = useCurrentIndex ( items ) ;
124-
12580 return (
12681 < div
12782 aria-label = { intl . formatMessage ( intlMessages . aria ) }
@@ -131,7 +86,7 @@ const Thumbnails = ({
13186 onMouseLeave = { ( ) => interaction . current = false }
13287 tabIndex = "0"
13388 >
134- { items . reduce ( ( result , item , index ) => {
89+ { storage . thumbnails . reduce ( ( result , item , index ) => {
13590 if ( ! isFiltered ( index ) ) {
13691 const active = index === currentIndex ;
13792
0 commit comments