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

Add keyboard shortcut to close the current conversation #5253

Merged
merged 3 commits into from
Nov 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Close all active modals when home shortcut is used
Signed-off-by: Heiko Carrasco <heiko.carrasco@yahoo.com>
miterion committed Oct 13, 2020
commit d7f15985f590232a72be980570d98d81b7efd45c
9 changes: 9 additions & 0 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
@@ -147,6 +147,15 @@ export class ModalManager {
return this.appendDialogAsync<T>(...rest);
}

public closeCurrentModal(reason: string) {
const modal = this.getCurrentModal();
if (!modal) {
return;
}
modal.closeReason = reason;
modal.close();
}

private buildModal<T extends any[]>(
prom: Promise<React.ComponentType>,
props?: IProps<T>,
2 changes: 2 additions & 0 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ import RoomListStore from "../../stores/room-list/RoomListStore";
import NonUrgentToastContainer from "./NonUrgentToastContainer";
import { ToggleRightPanelPayload } from "../../dispatcher/payloads/ToggleRightPanelPayload";
import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
import Modal from "../../Modal";

// We need to fetch each pinned message individually (if we don't already have it)
// so each pinned message may trigger a request. Limit the number per room for sanity.
@@ -450,6 +451,7 @@ class LoggedInView extends React.Component<IProps, IState> {
dis.dispatch({
action: 'view_home_page',
});
Modal.closeCurrentModal("homeKeyboardShortcut");
handled = true;
}
break;