@@ -34,6 +34,13 @@ import AddToCollectionList from '../components/AddToCollectionList';
34
34
import Feedback from '../components/Feedback' ;
35
35
import { CollectionSearchbar } from '../components/Searchbar' ;
36
36
37
+ const getTitle = ( props ) => {
38
+ const { id } = props . project ;
39
+ return id ? `p5.js Web Editor | ${ props . project . name } ` : 'p5.js Web Editor' ;
40
+ } ;
41
+
42
+ const isUserOwner = props => props . project . owner && props . project . owner . id === props . user . id ;
43
+
37
44
class IDEView extends React . Component {
38
45
constructor ( props ) {
39
46
super ( props ) ;
@@ -92,7 +99,7 @@ class IDEView extends React.Component {
92
99
}
93
100
94
101
componentDidUpdate ( prevProps ) {
95
- if ( this . isUserOwner ( this . props ) && this . props . project . id ) {
102
+ if ( isUserOwner ( this . props ) && this . props . project . id ) {
96
103
if ( this . props . preferences . autosave && this . props . ide . unsavedChanges && ! this . props . ide . justOpenedProject ) {
97
104
if (
98
105
this . props . selectedFile . name === prevProps . selectedFile . name &&
@@ -123,19 +130,12 @@ class IDEView extends React.Component {
123
130
this . autosaveInterval = null ;
124
131
}
125
132
126
- getTitle = ( props ) => {
127
- const { id } = props . project ;
128
- return id ? `p5.js Web Editor | ${ props . project . name } ` : 'p5.js Web Editor' ;
129
- }
130
-
131
- isUserOwner = props => props . project . owner && props . project . owner . id === props . user . id ;
132
-
133
133
handleGlobalKeydown ( e ) {
134
134
// 83 === s
135
135
if ( e . keyCode === 83 && ( ( e . metaKey && this . isMac ) || ( e . ctrlKey && ! this . isMac ) ) ) {
136
136
e . preventDefault ( ) ;
137
137
e . stopPropagation ( ) ;
138
- if ( this . isUserOwner ( this . props ) || ( this . props . user . authenticated && ! this . props . project . owner ) ) {
138
+ if ( isUserOwner ( this . props ) || ( this . props . user . authenticated && ! this . props . project . owner ) ) {
139
139
this . props . saveProject ( this . cmController . getContent ( ) ) ;
140
140
} else if ( this . props . user . authenticated ) {
141
141
this . props . cloneProject ( ) ;
@@ -206,7 +206,7 @@ class IDEView extends React.Component {
206
206
return (
207
207
< div className = "ide" >
208
208
< Helmet >
209
- < title > { this . getTitle ( this . props ) } </ title >
209
+ < title > { getTitle ( this . props ) } </ title >
210
210
</ Helmet >
211
211
{ this . props . toast . isVisible && < Toast /> }
212
212
< Nav
@@ -311,7 +311,7 @@ class IDEView extends React.Component {
311
311
isExpanded = { this . props . ide . sidebarIsExpanded }
312
312
expandSidebar = { this . props . expandSidebar }
313
313
collapseSidebar = { this . props . collapseSidebar }
314
- isUserOwner = { this . isUserOwner ( this . props ) }
314
+ isUserOwner = { isUserOwner ( this . props ) }
315
315
clearConsole = { this . props . clearConsole }
316
316
consoleEvents = { this . props . console }
317
317
showRuntimeErrorWarning = { this . props . showRuntimeErrorWarning }
0 commit comments