Fedor Indutnyy 2022-04-06 10:24:56 -07:00
commit 3c6d50f351
6 changed files with 22 additions and 9 deletions

View file

@ -16,6 +16,7 @@ import type { ConversationType } from '../../state/ducks/conversations';
import { LeftPaneSearchInput } from '../LeftPaneSearchInput';
import type { LeftPaneSearchPropsType } from './LeftPaneSearchHelper';
import { LeftPaneSearchHelper } from './LeftPaneSearchHelper';
import * as KeyboardLayout from '../../services/keyboardLayout';
type LeftPaneArchiveBasePropsType = {
archivedConversations: ReadonlyArray<ConversationListItemPropsType>;
@ -219,17 +220,18 @@ export class LeftPaneArchiveHelper extends LeftPaneHelper<LeftPaneArchivePropsTy
return;
}
const { ctrlKey, metaKey, shiftKey, key } = event;
const { ctrlKey, metaKey, shiftKey } = event;
const commandKey = window.platform === 'darwin' && metaKey;
const controlKey = window.platform !== 'darwin' && ctrlKey;
const commandOrCtrl = commandKey || controlKey;
const commandAndCtrl = commandKey && ctrlKey;
const key = KeyboardLayout.lookup(event);
if (
commandOrCtrl &&
!commandAndCtrl &&
shiftKey &&
key.toLowerCase() === 'f' &&
(key === 'f' || key === 'F') &&
this.archivedConversations.some(({ id }) => id === selectedConversationId)
) {
searchInConversation(selectedConversationId);

View file

@ -1,6 +1,8 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as KeyboardLayout from '../../services/keyboardLayout';
export function handleKeydownForSearch(
event: Readonly<KeyboardEvent>,
{
@ -13,13 +15,14 @@ export function handleKeydownForSearch(
startSearch: () => unknown;
}>
): void {
const { ctrlKey, metaKey, shiftKey, key } = event;
const { ctrlKey, metaKey, shiftKey } = event;
const commandKey = window.platform === 'darwin' && metaKey;
const controlKey = window.platform !== 'darwin' && ctrlKey;
const commandOrCtrl = commandKey || controlKey;
const commandAndCtrl = commandKey && ctrlKey;
const key = KeyboardLayout.lookup(event);
if (commandOrCtrl && !commandAndCtrl && key.toLowerCase() === 'f') {
if (commandOrCtrl && !commandAndCtrl && (key === 'f' || key === 'F')) {
if (!shiftKey) {
startSearch();
event.preventDefault();