Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Mar 8, 2024
1 parent cb7cd39 commit 7ea55e9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 41 deletions.
2 changes: 0 additions & 2 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,6 @@ class LoggedInView extends React.Component<IProps, IState> {
PlatformPeg.get()?.navigateForwardBack(false);
handled = true;
break;
case KeyBindingAction.SelectPrevMessage:
handled = true;
}

// Handle labs actions here, as they apply within the same scope
Expand Down
71 changes: 35 additions & 36 deletions src/components/structures/MessagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import { _t } from "../../languageHandler";
import { getLateEventInfo } from "./grouper/LateEventGrouper";
import { getKeyBindingsManager } from "../../KeyBindingsManager";
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
import { highlightEvent } from "../../utils/EventUtils";

const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes
const continuedTypes = [EventType.Sticker, EventType.RoomMessage];
Expand Down Expand Up @@ -427,43 +426,43 @@ export default class MessagePanel extends React.Component<IProps, IState> {
*/
public handleScrollKey(ev: React.KeyboardEvent | KeyboardEvent): void {
const navAction = getKeyBindingsManager().getNavigationAction(ev);
switch (navAction) {
case KeyBindingAction.SelectPrevMessage:
case KeyBindingAction.SelectNextMessage:
const events: WrappedEvent[] = this.props.events.map((event) => {
return { event, shouldShow: this.shouldShowEvent(event) };
});
const currentEventId = this.focusedEventId || this.props.highlightedEventId || events[events.length-1]?.event.getId()!;
if ( navAction === KeyBindingAction.SelectPrevMessage ) {
events.reverse();
}
let previousEventId = null;
for (let i = events.length - 1; i >= 0; i--) {
const { event, shouldShow } = events[i];
if (!shouldShow) {
continue;
}
const eventId = event.getId()!;
if ( previousEventId && eventId === currentEventId ) {
console.log('.mx_EventTile[data-event-id="' + previousEventId + '"]');

document.querySelector('.mx_EventTile[data-event-id="' + previousEventId + '"]')?.focus();
this.focusedEventId = previousEventId;
ev.preventDefault();
return;
}
previousEventId = eventId;
if (navAction === KeyBindingAction.SelectPrevMessage || navAction === KeyBindingAction.SelectNextMessage) {
const events: WrappedEvent[] = this.props.events.map((event) => {
return { event, shouldShow: this.shouldShowEvent(event) };
});
const currentEventId =
this.focusedEventId ||
this.props.highlightedEventId ||
(events[events.length - 1] ? events[events.length - 1].event.getId()! : null);
if (navAction === KeyBindingAction.SelectPrevMessage) {
events.reverse();
}
let previousEventId = null;
for (let i = events.length - 1; i >= 0; i--) {
const { event, shouldShow } = events[i];
if (!shouldShow) {
continue;
}
if ( navAction === KeyBindingAction.SelectNextMessage ) {
defaultDispatcher.dispatch(
{
action: Action.FocusSendMessageComposer,
context: TimelineRenderingType.Room,
},
true,
);
const eventId = event.getId()!;
if (previousEventId && eventId === currentEventId) {
console.log('.mx_EventTile[data-event-id="' + previousEventId + '"]');

document.querySelector('.mx_EventTile[data-event-id="' + previousEventId + '"]')?.focus();

Check failure on line 450 in src/components/structures/MessagePanel.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'focus' does not exist on type 'Element'.
this.focusedEventId = previousEventId;
ev.preventDefault();
return;
}
break;
previousEventId = eventId;
}
if (navAction === KeyBindingAction.SelectNextMessage) {
defaultDispatcher.dispatch(
{
action: Action.FocusSendMessageComposer,
context: TimelineRenderingType.Room,
},
true,
);
}
}

this.scrollPanel.current?.handleScrollKey(ev);
Expand Down
10 changes: 8 additions & 2 deletions src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,10 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
"ref": this.ref,
"className": classes,
"aria-live": ariaLive,
"aria-label": this.props.mxEvent.sender.name + '. ' + (this.props.mxEvent.clearEvent || this.props.mxEvent.event).content.body,
"aria-label":
this.props.mxEvent.sender.name +

Check failure on line 1214 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Object is possibly 'null'.
". " +
(this.props.mxEvent.clearEvent || this.props.mxEvent.event).content.body,

Check failure on line 1216 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Object is possibly 'undefined'.

Check failure on line 1216 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'clearEvent' is private and only accessible within class 'MatrixEvent'.
"aria-atomic": true,
"data-scroll-tokens": scrollToken,
"data-has-reply": !!replyChain,
Expand Down Expand Up @@ -1400,7 +1403,10 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
"className": classes,
"tabIndex": -1,
"aria-live": ariaLive,
"aria-label": this.props.mxEvent.sender.name + '. ' + (this.props.mxEvent.clearEvent || this.props.mxEvent.event).content.body,
"aria-label":
this.props.mxEvent.sender.name +

Check failure on line 1407 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Object is possibly 'null'.
". " +
(this.props.mxEvent.clearEvent || this.props.mxEvent.event).content.body,

Check failure on line 1409 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Object is possibly 'undefined'.

Check failure on line 1409 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'clearEvent' is private and only accessible within class 'MatrixEvent'.
"aria-atomic": "true",
"data-scroll-tokens": scrollToken,
"data-layout": this.props.layout,
Expand Down
4 changes: 3 additions & 1 deletion src/components/views/rooms/SendMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
const navAction = getKeyBindingsManager().getNavigationAction(event);
switch (navAction) {
case KeyBindingAction.SelectPrevMessage:
(document.querySelector('.mx_EventTile_selected')||document.querySelector('.mx_EventTile_last'))?.focus();
(
document.querySelector(".mx_EventTile_selected") || document.querySelector(".mx_EventTile_last")
)?.focus();

Check failure on line 316 in src/components/views/rooms/SendMessageComposer.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Property 'focus' does not exist on type 'Element'.
event.preventDefault();
event.stopPropagation();
return;
Expand Down

0 comments on commit 7ea55e9

Please sign in to comment.