File tree Expand file tree Collapse file tree 9 files changed +493
-739
lines changed Expand file tree Collapse file tree 9 files changed +493
-739
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import '../../../utils/htmlmixed';
44
44
import '../../../utils/p5-javascript' ;
45
45
import Timer from '../components/Timer' ;
46
46
import EditorAccessibility from '../components/EditorAccessibility' ;
47
+ import { selectActiveFile } from '../selectors/files' ;
47
48
import AssetPreview from './AssetPreview' ;
48
49
import { metaKey } from '../../../utils/metaKey' ;
49
50
import './show-hint' ;
@@ -605,10 +606,7 @@ Editor.propTypes = {
605
606
function mapStateToProps ( state ) {
606
607
return {
607
608
files : state . files ,
608
- file :
609
- state . files . find ( ( file ) => file . isSelectedFile ) ||
610
- state . files . find ( ( file ) => file . name === 'sketch.js' ) ||
611
- state . files . find ( ( file ) => file . name !== 'root' ) ,
609
+ file : selectActiveFile ( state ) ,
612
610
htmlFile : getHTMLFile ( state . files ) ,
613
611
ide : state . ide ,
614
612
preferences : state . preferences ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { setLanguage } from '../../actions/preferences';
14
14
import NavBar from '../../../../components/Nav/NavBar' ;
15
15
import CaretLeftIcon from '../../../../images/left-arrow.svg' ;
16
16
import LogoIcon from '../../../../images/p5js-logo-small.svg' ;
17
+ import { selectRootFile } from '../../selectors/files' ;
17
18
import { selectSketchPath } from '../../selectors/project' ;
18
19
import { metaKey , metaKeyName } from '../../../../utils/metaKey' ;
19
20
import { useSketchActions } from '../../hooks' ;
@@ -111,17 +112,14 @@ const DashboardMenu = () => {
111
112
) ;
112
113
} ;
113
114
114
- const ProjectMenu = ( props ) => {
115
+ const ProjectMenu = ( ) => {
115
116
const isUserOwner = useSelector ( getIsUserOwner ) ;
116
117
const project = useSelector ( ( state ) => state . project ) ;
117
118
const user = useSelector ( ( state ) => state . user ) ;
118
119
119
120
const isUnsaved = ! project ?. id ;
120
121
121
- // TODO: use selectRootFile selector
122
- const rootFile = useSelector (
123
- ( state ) => state . files . filter ( ( file ) => file . name === 'root' ) [ 0 ]
124
- ) ;
122
+ const rootFile = useSelector ( selectRootFile ) ;
125
123
126
124
const cmRef = useContext ( CmControllerContext ) ;
127
125
You can’t perform that action at this time.
0 commit comments