Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcuts to modals #2977

Merged
merged 10 commits into from
Mar 28, 2024
11 changes: 10 additions & 1 deletion ts/components/conversation/SessionConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ import { isAudio } from '../../types/MIME';
import { HTMLDirection } from '../../util/i18n';
import { NoticeBanner } from '../NoticeBanner';
import { SessionSpinner } from '../basic/SessionSpinner';
import { deleteMessagesByIdForEveryone } from '../../interactions/conversations/unsendingInteractions';
import { RightPanel, StyledRightPanelContainer } from './right-panel/RightPanel';

const DEFAULT_JPEG_QUALITY = 0.85;

interface State {
isDraggingFile: boolean;
}
Expand Down Expand Up @@ -353,6 +353,15 @@ export class SessionConversation extends React.Component<Props, State> {
window.inboxStore?.dispatch(resetSelectedMessageIds());
}
break;
case 'Backspace':
case 'Delete':
if (selectionMode) {
void deleteMessagesByIdForEveryone(
Bilb marked this conversation as resolved.
Show resolved Hide resolved
this.props.selectedMessages,
this.props.selectedConversationKey
);
}
break;
default:
}
}
Expand Down
9 changes: 9 additions & 0 deletions ts/components/dialog/SessionConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { shell } from 'electron';
import React, { Dispatch, useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
import styled from 'styled-components';
import useKey from 'react-use/lib/useKey';
import { useLastMessage } from '../../hooks/useParamSelector';
import { MessageInteraction } from '../../interactions';
import {
Expand Down Expand Up @@ -119,6 +120,14 @@ export const SessionConfirm = (props: SessionConfirmDialogProps) => {
}
};

useKey('Enter', () => {
void onClickOkHandler();
});

useKey('Escape', () => {
onClickCancelHandler();
});

useEffect(() => {
if (isLoading) {
if (conversationId && lastMessage?.interactionType) {
Expand Down
Loading