Restores ESC to close preferences
This commit is contained in:
parent
424d8785b6
commit
c304cb84fe
3 changed files with 21 additions and 1 deletions
|
@ -101,8 +101,9 @@ const createProps = (): PropsType => ({
|
||||||
zoomFactor: 1,
|
zoomFactor: 1,
|
||||||
|
|
||||||
addCustomColor: action('addCustomColor'),
|
addCustomColor: action('addCustomColor'),
|
||||||
editCustomColor: action('editCustomColor'),
|
closeSettings: action('closeSettings'),
|
||||||
doDeleteAllData: action('doDeleteAllData'),
|
doDeleteAllData: action('doDeleteAllData'),
|
||||||
|
editCustomColor: action('editCustomColor'),
|
||||||
getConversationsWithCustomColor: () => Promise.resolve([]),
|
getConversationsWithCustomColor: () => Promise.resolve([]),
|
||||||
initialSpellCheckSetting: true,
|
initialSpellCheckSetting: true,
|
||||||
makeSyncRequest: () => {
|
makeSyncRequest: () => {
|
||||||
|
|
|
@ -76,6 +76,7 @@ export type PropsType = {
|
||||||
|
|
||||||
// Other props
|
// Other props
|
||||||
addCustomColor: (color: CustomColorType) => unknown;
|
addCustomColor: (color: CustomColorType) => unknown;
|
||||||
|
closeSettings: () => unknown;
|
||||||
doDeleteAllData: () => unknown;
|
doDeleteAllData: () => unknown;
|
||||||
editCustomColor: (colorId: string, color: CustomColorType) => unknown;
|
editCustomColor: (colorId: string, color: CustomColorType) => unknown;
|
||||||
getConversationsWithCustomColor: (
|
getConversationsWithCustomColor: (
|
||||||
|
@ -158,6 +159,7 @@ export const Preferences = ({
|
||||||
availableMicrophones,
|
availableMicrophones,
|
||||||
availableSpeakers,
|
availableSpeakers,
|
||||||
blockedCount,
|
blockedCount,
|
||||||
|
closeSettings,
|
||||||
customColors,
|
customColors,
|
||||||
defaultConversationColor,
|
defaultConversationColor,
|
||||||
deviceName = '',
|
deviceName = '',
|
||||||
|
@ -249,6 +251,22 @@ export const Preferences = ({
|
||||||
document.body.classList.toggle('dark-theme', theme === ThemeType.dark);
|
document.body.classList.toggle('dark-theme', theme === ThemeType.dark);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
closeSettings();
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener('keydown', handler);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('keydown', handler);
|
||||||
|
};
|
||||||
|
}, [closeSettings]);
|
||||||
|
|
||||||
const onZoomSelectChange = useCallback(
|
const onZoomSelectChange = useCallback(
|
||||||
(value: string) => {
|
(value: string) => {
|
||||||
const number = parseFloat(value);
|
const number = parseFloat(value);
|
||||||
|
|
|
@ -291,6 +291,7 @@ async function renderPreferences() {
|
||||||
|
|
||||||
// Actions and other props
|
// Actions and other props
|
||||||
addCustomColor: ipcAddCustomColor,
|
addCustomColor: ipcAddCustomColor,
|
||||||
|
closeSettings: () => ipcRenderer.send('close-settings'),
|
||||||
doDeleteAllData: () => ipcRenderer.send('delete-all-data'),
|
doDeleteAllData: () => ipcRenderer.send('delete-all-data'),
|
||||||
editCustomColor: ipcEditCustomColor,
|
editCustomColor: ipcEditCustomColor,
|
||||||
getConversationsWithCustomColor: ipcGetConversationsWithCustomColor,
|
getConversationsWithCustomColor: ipcGetConversationsWithCustomColor,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue