import { h, Component } from 'preact' import { connect } from 'react-redux' import actions from '../actions' const image_types = { 'jpg': 'image/jpeg', 'jpeg': 'image/jpeg', 'png': 'image/png', 'gif': 'image/gif', } const audio_types = { 'wav': 'audio/wav', 'mp3': 'audio/mp3', 'flac': 'audio/flac', 'aiff': 'audio/aiff', } const video_types = { 'mp4': 'video/mp4', } class FileViewer extends Component { state = { loading: true, buffer: {} } fetch() { const { file } = this.props const fn = [file.path, file.name].join('/').replace('//','/') console.log('fetch file', fn) const { tool: module } = this.props.app this.setState({ buffer: null, loading: true }) actions.socket.read_file({ module, fn }).then(buffer => { console.log(buffer) this.setState({ buffer, loading: false }) }) } componentDidMount(){ this.fetch() } componentDidUpdate(nextProps){ if (this.props.file !== nextProps.file) { this.fetch() } } render() { const { loading, buffer } = this.state if (loading) { return