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

Commit

Permalink
refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
farooqkz committed Feb 2, 2024
1 parent e052887 commit 5fb01bd
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/RoomView/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,11 @@ class RoomView extends Component<RoomViewProps, RoomViewState> {
}

if (this.state.imageViewer) {
if (!this.imageViewer) {
alert("Image viewer is null! This is a bug. please report it :)");
return;
}
if (evt.key.startsWith("Arrow")) {
let key = evt.key.replace("Arrow", "").toLowerCase();
this.imageViewer.move(key);
} else if (VALID_KEYS.slice(0, 2).includes(evt.key)) {
// if it is backspace
evt.preventDefault();
this.setState({ imageViewer: false });
}
this.handleImageViewerEvents(evt);
return;
}
const lastEventIndex = this.getVisibleEvents().length - 1;
if (VALID_KEYS.slice(0, 2).includes(evt.key)) {
if (evt.key === "Backspace" || evt.key === "b") {
if (textInputFocus && message) return;
evt.preventDefault();
closeRoomView();
Expand All @@ -167,6 +156,20 @@ class RoomView extends Component<RoomViewProps, RoomViewState> {
}
}
};

handleImageViewerEvents = (evt: KeyboardEvent) => {
if (!this.imageViewer) {
alert("Image viewer is null! This is a bug. please report it :)");
return;
}
if (evt.key.startsWith("Arrow")) {
let key = evt.key.replace("Arrow", "").toLowerCase();
this.imageViewer.move(key);
} else if (evt.key === "Backspace" || evt.key === "b") {
evt.preventDefault();
this.setState({ imageViewer: false });
}
};

handleTimelineUpdate = (evt: MatrixEvent, room: Room | undefined) => {
if (!room) {
Expand Down

0 comments on commit 5fb01bd

Please sign in to comment.