import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { Route, Link } from 'react-router-dom' import moment from 'moment/min/moment.min' import util from '../../../util' import { FileViewer, Timeline, Param, Button, Group, TextInput } from '../../../common' import * as pix2pixhdTasks from '../pix2pixhd.tasks' import actions from '../../../actions' const initialState = { dir: '/', cursor: null, selection: null, title: null, } class SequenceEditor extends Component { state = { ...initialState } constructor() { super() this.handleCursor = this.handleCursor.bind(this) this.handleSelect = this.handleSelect.bind(this) } componentDidMount() { const { checkpoint } = this.props if (checkpoint) { this.reset() } } componentDidUpdate(prevProps) { const { checkpoint } = this.props if (checkpoint !== prevProps.checkpoint) { this.reset() } } reset(){ const { checkpoint } = this.props if (!(checkpoint && checkpoint.sequence)) return // console.log(checkpoint) this.setState({ ...initialState, title: checkpoint.name + '_' + moment().format("YYYYMMDD") }) } handleCursor(cursor) { this.setState({ cursor }) } handleSelect(selection) { this.setState({ selection }) } render() { const { app, pix2pixhd, remote, checkpoint, folder_id, processed } = this.props const { cursor, selection, title } = this.state const path = "sequences/" + checkpoint.name // console.log(checkpoint, pix2pixhd) return (
{selection ?
{selection.end.i - selection.start.i}{' frames'} {util.frameTimestamp(selection.end.i - selection.start.i)} this.setState({ title: title.replace(/ /g, '_').replace(/\/\./g, '') })} />
:
Please select some frames
}
{selection && selection.start && } {selection && selection.end && }
) } } function Frame ({ label, path, frame }) { if (!frame) return
return (
{label} {'#'}{frame.i} {util.frameTimestamp(frame.i)}
) } const mapStateToProps = state => ({ app: state.system.app, pix2pixhd: state.module.pix2pixhd, }) const mapDispatchToProps = (dispatch, ownProps) => ({ remote: bindActionCreators(pix2pixhdTasks, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(SequenceEditor)