File tree Expand file tree Collapse file tree 10 files changed +502
-742
lines changed
Expand file tree Collapse file tree 10 files changed +502
-742
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import '../../../utils/htmlmixed';
4444import '../../../utils/p5-javascript' ;
4545import Timer from '../components/Timer' ;
4646import EditorAccessibility from '../components/EditorAccessibility' ;
47+ import { selectActiveFile } from '../selectors/files' ;
4748import AssetPreview from './AssetPreview' ;
4849import { metaKey } from '../../../utils/metaKey' ;
4950import './show-hint' ;
@@ -605,10 +606,7 @@ Editor.propTypes = {
605606function mapStateToProps ( state ) {
606607 return {
607608 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 ) ,
612610 htmlFile : getHTMLFile ( state . files ) ,
613611 ide : state . ide ,
614612 preferences : state . preferences ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { setLanguage } from '../../actions/preferences';
1414import NavBar from '../../../../components/Nav/NavBar' ;
1515import CaretLeftIcon from '../../../../images/left-arrow.svg' ;
1616import LogoIcon from '../../../../images/p5js-logo-small.svg' ;
17+ import { selectRootFile } from '../../selectors/files' ;
1718import { selectSketchPath } from '../../selectors/project' ;
1819import { metaKey , metaKeyName } from '../../../../utils/metaKey' ;
1920import { useSketchActions } from '../../hooks' ;
@@ -111,17 +112,14 @@ const DashboardMenu = () => {
111112 ) ;
112113} ;
113114
114- const ProjectMenu = ( props ) => {
115+ const ProjectMenu = ( ) => {
115116 const isUserOwner = useSelector ( getIsUserOwner ) ;
116117 const project = useSelector ( ( state ) => state . project ) ;
117118 const user = useSelector ( ( state ) => state . user ) ;
118119
119120 const isUnsaved = ! project ?. id ;
120121
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 ) ;
125123
126124 const cmRef = useContext ( CmControllerContext ) ;
127125
You can’t perform that action at this time.
0 commit comments