import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { Link } from 'react-router-dom';
import { connect } from 'react-redux'
import util from '../../../util'
import actions from '../../../actions'
import * as morphActions from '../morph.actions'
import * as morphTasks from '../morph.tasks'
import Loading from '../../../common/loading.component'
import {
Select, Slider, Checkbox, Group,
Button, Param, FileList, FileRow,
CurrentTask,
} from '../../../common'
let yes_count = 0
class MorphResults extends Component {
constructor(props){
super()
this.state = {
dataset_module: 'pix2pixhd',
a: "PLACEHOLDER",
b: "PLACEHOLDER",
a_offset: 0,
a_duration: 1,
a_pos: 0,
b_offset: 0,
b_duration: 1,
b_pos: 0,
steps: 16,
dilate: 2,
frames: 32,
padding: 3,
smooth: true,
mode: 'mix',
}
if (!props.morph.data) props.actions.load_data()
}
componentDidMount(){
yes_count = 0
}
render(){
if (! this.props.morph.app) return
const { resultsFolder, sequences, renders, files } = this.props.morph.app
const sequence_options = sequences.map(sequence => [
sequence.name.split("_").slice(0, 3).join(" ") + "~ (" + sequence.count + ")",
sequence.name
])
const sequenceLookup = sequences.reduce((a,b) => (a[b.name]=b,a), {})
const totalLength = this.state.frames / 25
let lengthWarning
if ((this.state.steps / this.state.dilate) > 64 && this.state.mode === 'mix') {
lengthWarning = (
warning, this will take a while
)
}
return (
Morph
morphed videos
{
let yes;
if (yes_count < 3) {
yes = confirm('Are you sure you want to delete this file?')
} else {
yes = true
}
if (yes) {
yes_count += 1
console.log('delete: confirmed')
actions.file.destroy(file)
}
}}
/>
renders on server
{
e.preventDefault()
e.stopPropagation()
console.log('picked a result', file)
this.handlePick(file)
}}
/>
)
}
handlePick(file){
// this.props.audioPlayer.play(file)
}
}
const mapStateToProps = state => ({
morph: state.module.morph,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: bindActionCreators(morphActions, dispatch),
remote: bindActionCreators(morphTasks, dispatch),
// audioPlayer: bindActionCreators(audioPlayerActions, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(MorphResults)