feat: initialise editor with 'first' file

Since sort-files exists, the challengeFiles have an order. The editor
now displays the first file on mount.
This commit is contained in:
Oliver Eyton-Williams
2020-06-01 18:44:21 +02:00
committed by Mrugesh Mohapatra
parent f82886148c
commit 1a985f95f5

View File

@ -14,6 +14,7 @@ import {
} from '../redux';
import { userSelector, isDonationModalOpenSelector } from '../../../redux';
import { Loader } from '../../../components/helpers';
import { sortFiles } from '../utils/sort-files';
import './editor.css';
@ -129,10 +130,11 @@ class Editor extends Component {
}
};
const { challengeFiles } = this.props;
// NOTE: for consitency with this.data (and this.options) currentFileKey
// is just a property, not state.
this.currentFileKey = 'indexhtml';
this.currentFileKey = sortFiles(challengeFiles)[0].key;
this.options = {
fontSize: '18px',