Skip to content

Commit

Permalink
fix: enable use of escape on modals
Browse files Browse the repository at this point in the history
feat: confirm modal when enter is pressed

fix: fix linter issues

fix: update rebase and fix lint issues

fix: remove duplicate code
  • Loading branch information
KeeJef committed Mar 21, 2024
1 parent 2274667 commit 9b79080
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ts/components/conversation/SessionConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +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;
import { deleteMessagesByIdForEveryone } from '../../interactions/conversations/unsendingInteractions';
// tslint:disable: jsx-curly-spacing
interface State {
isDraggingFile: boolean;
}
Expand Down Expand Up @@ -353,11 +352,14 @@ export class SessionConversation extends React.Component<Props, State> {
if (selectionMode) {
window.inboxStore?.dispatch(resetSelectedMessageIds());
}
break;
break;
case 'Backspace':
case 'Delete':
if (selectionMode) {
void deleteMessagesByIdForEveryone(this.props.selectedMessages, this.props.selectedConversationKey);
void deleteMessagesByIdForEveryone(
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

0 comments on commit 9b79080

Please sign in to comment.