import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import {
Loading, Group, Slider, Button
} from '../../../common/'
import actions from '../../../actions'
import * as bigganTasks from '../biggan.tasks'
import * as bigganActions from '../biggan.actions'
import { frameTimestamp } from '../../../util/format'
class BigGANEncodingList extends Component {
state = {
file_id: 0,
}
componentDidMount() {
if (!this.props.biggan.encodings) {
this.props.actions.biggan.load_encodings()
}
}
render() {
const { file_id } = this.state
const { opt, frame } = this.props
const { encodings, encoding_order } = this.props.biggan
if (!encodings) {
return
Loading encodings...
}
return (
{frame.i ?
Frame #{frame.i}
{frameTimestamp(frame.i)}
:
}
this.categoryRef = ref}>
{encoding_order.map(name => {
return (
{name}
{encodings[name].map(file => (

{
actions.live.send_command('setEncoding', JSON.stringify({
id: file.id,
}))
this.setState({ file_id: file.id })
}}
/>
))}
)
})}
)
}
}
const mapStateToProps = state => ({
last_message: state.live.last_message,
opt: state.live.opt,
frame: state.live.frame,
biggan: state.module.biggan,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: {
biggan: bindActionCreators(bigganActions, dispatch),
tasks: bindActionCreators(bigganTasks, dispatch),
}
})
export default connect(mapStateToProps, mapDispatchToProps)(BigGANEncodingList)