Skip to content

Commit

Permalink
Code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
supnate committed Mar 10, 2018
1 parent 63ed3ea commit fdf7eeb
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions packages/rekit-studio/src/features/home/CodeEditor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint no-bitwise: 0, jsx-no-bind: 0*/
/* eslint no-bitwise: 0, jsx-no-bind: 0 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Prompt } from 'react-router';
import axios from 'axios';
import { Button, Icon, message, Modal, Spin, Tooltip } from 'antd';
import { MonacoEditor } from '../common';
Expand Down Expand Up @@ -44,7 +43,6 @@ export class CodeEditor extends Component {

state = {
notFound: false,
currentContent: '',
loadingFile: false,
loadingEditor: true,
cursorPos: {
Expand All @@ -62,7 +60,6 @@ export class CodeEditor extends Component {
modelManager.setInitialValue(this.props.file, this.getFileContent(this.props.file), true);
this.setState({
// eslint-disable-line
currentContent: this.getFileContent(),
loadingFile: false,
});
this.props.onStateChange({ hasChange: false });
Expand Down Expand Up @@ -101,7 +98,7 @@ export class CodeEditor extends Component {
cancelText: 'No',
onOk: () => {
modelManager.reset(nextProps.file);
}
},
});
}
}
Expand All @@ -126,11 +123,9 @@ export class CodeEditor extends Component {
this.editor.executeEdits('format', [
{ range: new monaco.Range(1, 1, 1000000, 1), text: res.data.content, forceMoveMarkers: true },
]);
this.setState(
{
loadingFile: false,
}
);
this.setState({
loadingFile: false,
});
})
.catch(() => {
this.setState({
Expand All @@ -139,16 +134,6 @@ export class CodeEditor extends Component {
});
};

reloadContent = () => {
// Reload content from Redux store to internal state(editor).
this.setState({
currentContent: this.getFileContent(),
});
if (this.editor) this.editor.setValue(this.getFileContent());
this.props.onStateChange({ hasChange: false });
this.recoverEditorState();
};

recoverEditorState = () => {
if (!this.editor) return;
const { file } = this.props;
Expand Down

0 comments on commit fdf7eeb

Please sign in to comment.