@@ -58,7 +58,6 @@ import { _t } from "../../languageHandler";
58
58
import { getLateEventInfo } from "./grouper/LateEventGrouper" ;
59
59
import { getKeyBindingsManager } from "../../KeyBindingsManager" ;
60
60
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts" ;
61
- import { highlightEvent } from "../../utils/EventUtils" ;
62
61
63
62
const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000 ; // 5 minutes
64
63
const continuedTypes = [ EventType . Sticker , EventType . RoomMessage ] ;
@@ -427,43 +426,43 @@ export default class MessagePanel extends React.Component<IProps, IState> {
427
426
*/
428
427
public handleScrollKey ( ev : React . KeyboardEvent | KeyboardEvent ) : void {
429
428
const navAction = getKeyBindingsManager ( ) . getNavigationAction ( ev ) ;
430
- switch ( navAction ) {
431
- case KeyBindingAction . SelectPrevMessage :
432
- case KeyBindingAction . SelectNextMessage :
433
- const events : WrappedEvent [ ] = this . props . events . map ( ( event ) => {
434
- return { event, shouldShow : this . shouldShowEvent ( event ) } ;
435
- } ) ;
436
- const currentEventId = this . focusedEventId || this . props . highlightedEventId || events [ events . length - 1 ] ?. event . getId ( ) ! ;
437
- if ( navAction === KeyBindingAction . SelectPrevMessage ) {
438
- events . reverse ( ) ;
439
- }
440
- let previousEventId = null ;
441
- for ( let i = events . length - 1 ; i >= 0 ; i -- ) {
442
- const { event, shouldShow } = events [ i ] ;
443
- if ( ! shouldShow ) {
444
- continue ;
445
- }
446
- const eventId = event . getId ( ) ! ;
447
- if ( previousEventId && eventId === currentEventId ) {
448
- console . log ( '.mx_EventTile[data-event-id="' + previousEventId + '"]' ) ;
449
-
450
- document . querySelector ( '.mx_EventTile[data-event-id="' + previousEventId + '"]' ) ?. focus ( ) ;
451
- this . focusedEventId = previousEventId ;
452
- ev . preventDefault ( ) ;
453
- return ;
454
- }
455
- previousEventId = eventId ;
429
+ if ( navAction === KeyBindingAction . SelectPrevMessage || navAction === KeyBindingAction . SelectNextMessage ) {
430
+ const events : WrappedEvent [ ] = this . props . events . map ( ( event ) => {
431
+ return { event, shouldShow : this . shouldShowEvent ( event ) } ;
432
+ } ) ;
433
+ const currentEventId =
434
+ this . focusedEventId ||
435
+ this . props . highlightedEventId ||
436
+ ( events [ events . length - 1 ] ? events [ events . length - 1 ] . event . getId ( ) ! : null ) ;
437
+ if ( navAction === KeyBindingAction . SelectPrevMessage ) {
438
+ events . reverse ( ) ;
439
+ }
440
+ let previousEventId = null ;
441
+ for ( let i = events . length - 1 ; i >= 0 ; i -- ) {
442
+ const { event, shouldShow } = events [ i ] ;
443
+ if ( ! shouldShow ) {
444
+ continue ;
456
445
}
457
- if ( navAction === KeyBindingAction . SelectNextMessage ) {
458
- defaultDispatcher . dispatch (
459
- {
460
- action : Action . FocusSendMessageComposer ,
461
- context : TimelineRenderingType . Room ,
462
- } ,
463
- true ,
464
- ) ;
446
+ const eventId = event . getId ( ) ! ;
447
+ if ( previousEventId && eventId === currentEventId ) {
448
+ console . log ( '.mx_EventTile[data-event-id="' + previousEventId + '"]' ) ;
449
+
450
+ document . querySelector ( '.mx_EventTile[data-event-id="' + previousEventId + '"]' ) ?. focus ( ) ;
451
+ this . focusedEventId = previousEventId ;
452
+ ev . preventDefault ( ) ;
453
+ return ;
465
454
}
466
- break ;
455
+ previousEventId = eventId ;
456
+ }
457
+ if ( navAction === KeyBindingAction . SelectNextMessage ) {
458
+ defaultDispatcher . dispatch (
459
+ {
460
+ action : Action . FocusSendMessageComposer ,
461
+ context : TimelineRenderingType . Room ,
462
+ } ,
463
+ true ,
464
+ ) ;
465
+ }
467
466
}
468
467
469
468
this . scrollPanel . current ?. handleScrollKey ( ev ) ;
0 commit comments