diff --git a/src/Readme.js b/src/Readme.js index d2777f2f..0df1c9a5 100644 --- a/src/Readme.js +++ b/src/Readme.js @@ -1,49 +1,19 @@ import React from "react"; import { connect } from "react-redux"; -import { switchMap } from "rxjs/operators"; -import { from } from "rxjs"; -import Disposable from "./Disposable"; +import * as Actions from "./redux/actionCreators"; class Readme extends React.Component { - constructor(props) { - super(props); - this._disposable = new Disposable(); - this.state = { focusedFile: null }; - } - - componentDidMount() {} - - componentDidUpdate(_, oldState) {} - - componentWillUnmount() { - this._disposable.dispose(); - } - - async _focusFile(fileName) { - if (this.props.zip == null) { - return; - } - - const file = await this.props.zip.file(fileName); - const type = fileName - .split(".") - .pop() - .toLowerCase(); - const methodFromType = { - txt: "string", - bmp: "blob", - cur: "blob" - }; - let content = await file.async(methodFromType[type]); - this.setState({ focusedFile: { fileName, type, content } }); - } - _renderFocusedFile() { - if (this.state.focusedFile == null) { + if (this.props.focusedFile == null) { return; } - switch (this.state.focusedFile.type) { + const { ext, fileName, content } = this.props.focusedFile; + if (content == null) { + return; + } + + switch (ext) { case "txt": return ( + defaultValue={content} + /> ); case "bmp": case "cur": - const mimeType = `image/cur`; - const content = URL.createObjectURL( - new Blob([this.state.focusedFile.content], { type: mimeType }) + const mimeType = `image/${ext}`; + const url = URL.createObjectURL( + new Blob([content], { type: mimeType }) ); - return ; + return {fileName}; + default: + return null; } } @@ -77,24 +48,22 @@ class Readme extends React.Component { overflow: "scroll" }} > -