@@ -240,7 +240,7 @@ export const getEventIdAbsoluteIndex = (
240240 eventTimeline : EventTimeline ,
241241 eventId : string
242242) : number | undefined => {
243- const timelineIndex = timelines . findIndex ( ( t ) => t === eventTimeline ) ;
243+ const timelineIndex = timelines . indexOf ( eventTimeline ) ;
244244 if ( timelineIndex === - 1 ) return undefined ;
245245
246246 const currentEvents = eventTimeline . getEvents ( ) ;
@@ -285,17 +285,17 @@ const useEventTimelineLoader = (
285285 async ( eventId : string ) => {
286286 const withTimeout = async < T , > ( promise : Promise < T > , timeoutMs : number ) : Promise < T > =>
287287 new Promise < T > ( ( resolve , reject ) => {
288- const timeoutId = window . setTimeout ( ( ) => {
288+ const timeoutId = globalThis . setTimeout ( ( ) => {
289289 reject ( new Error ( 'Timed out loading event timeline' ) ) ;
290290 } , timeoutMs ) ;
291291
292292 promise
293293 . then ( ( value ) => {
294- window . clearTimeout ( timeoutId ) ;
294+ globalThis . clearTimeout ( timeoutId ) ;
295295 resolve ( value ) ;
296296 } )
297297 . catch ( ( error ) => {
298- window . clearTimeout ( timeoutId ) ;
298+ globalThis . clearTimeout ( timeoutId ) ;
299299 reject ( error ) ;
300300 } ) ;
301301 } ) ;
@@ -381,7 +381,7 @@ const useTimelinePagination = (
381381 const { linkedTimelines : lTimelines } = timelineRef . current ;
382382 const timelinesEventsCount = lTimelines . map ( timelineToEventsCount ) ;
383383
384- const timelineToPaginate = backwards ? lTimelines [ 0 ] : lTimelines [ lTimelines . length - 1 ] ;
384+ const timelineToPaginate = backwards ? lTimelines [ 0 ] : lTimelines . at ( - 1 ) ;
385385 if ( ! timelineToPaginate ) return ;
386386
387387 const paginationToken = timelineToPaginate . getPaginationToken (
@@ -688,8 +688,7 @@ export function RoomTimeline({
688688 eventId ? getEmptyTimeline ( ) : getInitialTimeline ( room )
689689 ) ;
690690 const eventsLength = getTimelinesEventsCount ( timeline . linkedTimelines ) ;
691- const liveTimelineLinked =
692- timeline . linkedTimelines [ timeline . linkedTimelines . length - 1 ] === getLiveTimeline ( room ) ;
691+ const liveTimelineLinked = timeline . linkedTimelines . at ( - 1 ) === getLiveTimeline ( room ) ;
693692 const canPaginateBack =
694693 typeof timeline . linkedTimelines [ 0 ] ?. getPaginationToken ( Direction . Backward ) === 'string' ;
695694 const rangeAtStart = timeline . range . start === 0 ;
@@ -1091,7 +1090,7 @@ export function RoomTimeline({
10911090
10921091 // scroll to focused message
10931092 useLayoutEffect ( ( ) => {
1094- if ( focusItem && focusItem . scrollTo ) {
1093+ if ( focusItem ? .scrollTo ) {
10951094 scrollToItem ( focusItem . index , {
10961095 behavior : 'instant' ,
10971096 align : 'center' ,
@@ -1357,7 +1356,7 @@ export function RoomTimeline({
13571356 {
13581357 [ MessageEvent . RoomMessage ] : ( mEventId , mEvent , item , timelineSet , collapse ) => {
13591358 const reactionRelations = getEventReactions ( timelineSet , mEventId ) ;
1360- const reactions = reactionRelations && reactionRelations . getSortedAnnotationsByKey ( ) ;
1359+ const reactions = reactionRelations ? .getSortedAnnotationsByKey ( ) ;
13611360 const hasReactions = reactions && reactions . length > 0 ;
13621361 const { replyEventId, threadRootId } = mEvent ;
13631362 const highlighted = focusItem ?. index === item && focusItem . highlight ;
@@ -1486,7 +1485,7 @@ export function RoomTimeline({
14861485 } ,
14871486 [ MessageEvent . RoomMessageEncrypted ] : ( mEventId , mEvent , item , timelineSet , collapse ) => {
14881487 const reactionRelations = getEventReactions ( timelineSet , mEventId ) ;
1489- const reactions = reactionRelations && reactionRelations . getSortedAnnotationsByKey ( ) ;
1488+ const reactions = reactionRelations ? .getSortedAnnotationsByKey ( ) ;
14901489 const hasReactions = reactions && reactions . length > 0 ;
14911490 const { replyEventId, threadRootId } = mEvent ;
14921491 const highlighted = focusItem ?. index === item && focusItem . highlight ;
@@ -1626,7 +1625,7 @@ export function RoomTimeline({
16261625 } ,
16271626 [ MessageEvent . Sticker ] : ( mEventId , mEvent , item , timelineSet , collapse ) => {
16281627 const reactionRelations = getEventReactions ( timelineSet , mEventId ) ;
1629- const reactions = reactionRelations && reactionRelations . getSortedAnnotationsByKey ( ) ;
1628+ const reactions = reactionRelations ? .getSortedAnnotationsByKey ( ) ;
16301629 const hasReactions = reactions && reactions . length > 0 ;
16311630 const { replyEventId, threadRootId } = mEvent ;
16321631 const highlighted = focusItem ?. index === item && focusItem . highlight ;
0 commit comments