diff --git a/client/modules/App/App.jsx b/client/modules/App/App.jsx
index 1da42325..af441a9d 100644
--- a/client/modules/App/App.jsx
+++ b/client/modules/App/App.jsx
@@ -34,8 +34,7 @@ class App extends React.Component {
render() {
return (
- {false &&
- this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && }
+ {this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && }
{this.props.children}
);
diff --git a/client/modules/IDE/pages/MobileIDEView.jsx b/client/modules/IDE/pages/MobileIDEView.jsx
index 2aa653b2..0ecdfc14 100644
--- a/client/modules/IDE/pages/MobileIDEView.jsx
+++ b/client/modules/IDE/pages/MobileIDEView.jsx
@@ -73,6 +73,9 @@ const getNatOptions = (username = undefined) =>
const isUserOwner = ({ project, user }) =>
project && project.owner && project.owner.id === user.id;
+const canSaveProject = (project, user) =>
+ isUserOwner({ project, user }) || (user.authenticated && !project.owner);
+
// TODO: This could go into
const handleGlobalKeydown = (props, cmController) => (e) => {
const {
@@ -113,7 +116,7 @@ const handleGlobalKeydown = (props, cmController) => (e) => {
// 83 === s
e.preventDefault();
e.stopPropagation();
- if (isUserOwner(props) || (user.authenticated && !project.owner)) saveProject(cmController.getContent());
+ if (canSaveProject(props)) saveProject(cmController.getContent());
else if (user.authenticated) cloneProject();
else showErrorModal('forceAuthentication');
@@ -205,8 +208,7 @@ const MobileIDEView = (props) => {
autosaveProject, preferences, ide, selectedFile
});
- // useEventListener('keydown', () => alert('haha'));
- useEventListener('keydown', handleGlobalKeydown(props, cmController));
+ useEventListener('keydown', handleGlobalKeydown(props, cmController), false, [props]);
return (
diff --git a/client/utils/custom-hooks.js b/client/utils/custom-hooks.js
index 7543555c..b0981ae0 100644
--- a/client/utils/custom-hooks.js
+++ b/client/utils/custom-hooks.js
@@ -53,7 +53,7 @@ export const useEffectWithComparison = (fn, props) => {
}, Object.values(props));
};
-export const useEventListener = (event, callback, useCapture = false) => useEffect(() => {
+export const useEventListener = (event, callback, useCapture = false, list = []) => useEffect(() => {
document.addEventListener(event, callback, useCapture);
return () => document.removeEventListener(event, callback, useCapture);
-}, []);
+}, list);