@@ -34,17 +34,14 @@ import About from '../components/About';
34
34
import AddToCollectionList from '../components/AddToCollectionList' ;
35
35
import Feedback from '../components/Feedback' ;
36
36
import { CollectionSearchbar } from '../components/Searchbar' ;
37
+ import { getIsUserOwner } from '../selectors/users' ;
37
38
38
39
39
40
function getTitle ( props ) {
40
41
const { id } = props . project ;
41
42
return id ? `p5.js Web Editor | ${ props . project . name } ` : 'p5.js Web Editor' ;
42
43
}
43
44
44
- function isUserOwner ( props ) {
45
- return props . project . owner && props . project . owner . id === props . user . id ;
46
- }
47
-
48
45
function warnIfUnsavedChanges ( props ) {
49
46
// eslint-disable-line
50
47
const { route } = props . route ;
@@ -138,7 +135,7 @@ class IDEView extends React.Component {
138
135
}
139
136
140
137
componentDidUpdate ( prevProps ) {
141
- if ( isUserOwner ( this . props ) && this . props . project . id ) {
138
+ if ( this . props . isUserOwner && this . props . project . id ) {
142
139
if (
143
140
this . props . preferences . autosave &&
144
141
this . props . ide . unsavedChanges &&
@@ -151,7 +148,6 @@ class IDEView extends React.Component {
151
148
if ( this . autosaveInterval ) {
152
149
clearTimeout ( this . autosaveInterval ) ;
153
150
}
154
- console . log ( 'will save project in 20 seconds' ) ;
155
151
this . autosaveInterval = setTimeout ( this . props . autosaveProject , 20000 ) ;
156
152
}
157
153
} else if ( this . autosaveInterval && ! this . props . preferences . autosave ) {
@@ -182,7 +178,7 @@ class IDEView extends React.Component {
182
178
e . preventDefault ( ) ;
183
179
e . stopPropagation ( ) ;
184
180
if (
185
- isUserOwner ( this . props ) ||
181
+ this . props . isUserOwner ||
186
182
( this . props . user . authenticated && ! this . props . project . owner )
187
183
) {
188
184
this . props . saveProject ( this . cmController . getContent ( ) ) ;
@@ -603,6 +599,7 @@ IDEView.propTypes = {
603
599
openUploadFileModal : PropTypes . func . isRequired ,
604
600
closeUploadFileModal : PropTypes . func . isRequired ,
605
601
t : PropTypes . func . isRequired ,
602
+ isUserOwner : PropTypes . bool . isRequired
606
603
} ;
607
604
608
605
function mapStateToProps ( state ) {
@@ -620,6 +617,7 @@ function mapStateToProps(state) {
620
617
project : state . project ,
621
618
toast : state . toast ,
622
619
console : state . console ,
620
+ isUserOwner : getIsUserOwner ( state )
623
621
} ;
624
622
}
625
623
0 commit comments