diff --git a/client/package.json b/client/package.json index 427b7cf8d..8bd8947b3 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "ontime-ui", - "version": "1.0.0", + "version": "1.0.1", "private": true, "dependencies": { "@chakra-ui/react": "^2.0.0-next.3", diff --git a/client/src/common/components/buttons/QuitIconBtn.jsx b/client/src/common/components/buttons/QuitIconBtn.jsx index 44b72cc14..bb5aabb10 100644 --- a/client/src/common/components/buttons/QuitIconBtn.jsx +++ b/client/src/common/components/buttons/QuitIconBtn.jsx @@ -1,4 +1,4 @@ -import React, { useCallback, useRef, useState } from 'react'; +import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; import { Button, IconButton } from '@chakra-ui/button'; import { AlertDialog, @@ -11,17 +11,28 @@ import { import { Tooltip } from '@chakra-ui/tooltip'; import { FiPower } from '@react-icons/all-files/fi/FiPower'; import PropTypes from 'prop-types'; +import { LoggingContext } from '../../../app/context/LoggingContext'; export default function QuitIconBtn(props) { const { clickHandler, size = 'lg', ...rest } = props; const [isOpen, setIsOpen] = useState(false); + const { emitInfo } = useContext(LoggingContext); const onClose = () => setIsOpen(false); const cancelRef = useRef(); + useEffect(() => { + if (window.process?.type === 'renderer') { + window.ipcRenderer.on('user-request-shutdown', () => { + emitInfo('Shutdown request') + setIsOpen(true); + }); + } + }, [emitInfo]); + const handleShutdown = useCallback(() => { onClose(); clickHandler(); - },[clickHandler]); + }, [clickHandler]); return ( <> diff --git a/client/src/features/menu/MenuBar.jsx b/client/src/features/menu/MenuBar.jsx index 5efd3ac66..f32a351c6 100644 --- a/client/src/features/menu/MenuBar.jsx +++ b/client/src/features/menu/MenuBar.jsx @@ -75,7 +75,7 @@ export default function MenuBar(props) { return; } - if (window.process.type === 'renderer') { + if (window.process?.type === 'renderer') { switch (action) { case 'min': window.ipcRenderer.send('set-window', 'to-tray'); diff --git a/server/main.js b/server/main.js index 036bc1433..f04103fc4 100644 --- a/server/main.js +++ b/server/main.js @@ -115,6 +115,12 @@ app.whenReady().then(() => { app.setAppUserModelId(app.name); } + // allow usual quit in mac + if (process.platform === 'darwin') { + globalShortcut.register('Command+Q', () => { + win.send('user-request-shutdown'); + }); + } createWindow(); // register global shortcuts diff --git a/server/package.json b/server/package.json index 1737bca83..9241a8312 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "ontime", - "version": "1.0.1", + "version": "1.0.2", "author": "Carlos Valente", "description": "Time keeping for live events", "repository": "https://github.com/cpvalente/ontime",