mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-18 23:49:20 +01:00
Rename files
This commit is contained in:
36
ts/components/leftPane/handleKeydownForSearch.dom.ts
Normal file
36
ts/components/leftPane/handleKeydownForSearch.dom.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as KeyboardLayout from '../../services/keyboardLayout.dom.js';
|
||||
|
||||
export function handleKeydownForSearch(
|
||||
event: Readonly<KeyboardEvent>,
|
||||
{
|
||||
searchInConversation,
|
||||
selectedConversationId,
|
||||
startSearch,
|
||||
}: Readonly<{
|
||||
searchInConversation: (conversationId: string) => unknown;
|
||||
selectedConversationId: undefined | string;
|
||||
startSearch: () => unknown;
|
||||
}>
|
||||
): void {
|
||||
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 === 'f' || key === 'F')) {
|
||||
if (!shiftKey) {
|
||||
startSearch();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
} else if (selectedConversationId) {
|
||||
searchInConversation(selectedConversationId);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user