From df495997f84b86f59ac417afb1b2509e5a64731d Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Fri, 9 Dec 2016 14:33:21 -0500 Subject: [PATCH] fix #215 --- client/modules/IDE/pages/IDEView.jsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 4277b420..2b81ad60 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -52,8 +52,7 @@ class IDEView extends React.Component { // if autosave is on and the user is the owner of the project if (this.props.preferences.autosave - && this.props.project.owner - && this.props.project.owner.id === this.props.user.id) { + && this.isUserOwner()) { this.autosaveInterval = setInterval(this.props.autosaveProject, 30000); } } @@ -104,7 +103,7 @@ class IDEView extends React.Component { componentDidUpdate(prevProps) { // if user is the owner of the project - if (this.props.project.owner && this.props.project.owner.id === this.props.user.id) { + if (this.isUserOwner()) { // if the user turns on autosave // or the user saves the project for the first time if (!this.autosaveInterval && @@ -135,6 +134,10 @@ class IDEView extends React.Component { this.sidebarSize = undefined; } + isUserOwner() { + return this.props.project.owner && this.props.project.owner.id === this.props.user.id; + } + _handleConsolePaneOnDragFinished() { this.consoleSize = this.refs.consolePane.state.draggedSize; this.refs.consolePane.setState({ @@ -156,7 +159,7 @@ class IDEView extends React.Component { if (e.keyCode === 83 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) { e.preventDefault(); e.stopPropagation(); - if (this.props.project.owner && this.props.project.owner.id === this.props.user.id) { + if (this.isUserOwner() || this.props.user.authenticated && !this.props.project.owner) { this.props.saveProject(); } // 13 === enter