mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
Fix/ios (#43)
* remove tiny keys
* fix: replace library with code
* cleanup
* add lodash throttle
add dependency to handle event throttling
* Revert "add lodash throttle"
This reverts commit abcbd3556b.
This commit is contained in:
+17
-9
@@ -1,10 +1,9 @@
|
||||
import { lazy, Suspense, useEffect } from 'react';
|
||||
import { lazy, Suspense, useCallback, useEffect } from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import './App.css';
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
import SocketProvider from 'app/context/socketContext';
|
||||
import withSocket from 'features/viewers/ViewWrapper';
|
||||
import tinykeys from 'tinykeys';
|
||||
|
||||
const Editor = lazy(() => import('features/editors/Editor'));
|
||||
const PresenterView = lazy(() =>
|
||||
@@ -37,21 +36,30 @@ const SLowerThird = withSocket(Lower);
|
||||
const SPip = withSocket(Pip);
|
||||
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
let unsubscribe = tinykeys(window, {
|
||||
'Alt+t': () => {
|
||||
// Handle keyboard shortcuts
|
||||
const handleKeyPress = useCallback((e) => {
|
||||
// check if the alt key is pressed
|
||||
if (e.altKey) {
|
||||
if (e.key === 't' || e.key === 'T') {
|
||||
// if we are in electron
|
||||
if (window.process?.type === undefined) return;
|
||||
if (window.process.type === 'renderer') {
|
||||
// ask to see debug
|
||||
window.ipcRenderer.send('set-window', 'show-dev');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// attach the event listener
|
||||
document.addEventListener('keydown', handleKeyPress);
|
||||
|
||||
// remove the event listener
|
||||
return () => {
|
||||
unsubscribe();
|
||||
document.removeEventListener('keydown', handleKeyPress);
|
||||
};
|
||||
});
|
||||
}, [handleKeyPress]);
|
||||
|
||||
return (
|
||||
<SocketProvider>
|
||||
|
||||
Reference in New Issue
Block a user