1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 22:08:02 +00:00

refactor: kaburiActivityを借りする責務をvad.jsxに移す

This commit is contained in:
kohei 2018-11-19 18:54:34 +09:00
parent 0508d129c7
commit f5983bb9bd
2 changed files with 7 additions and 8 deletions

View file

@ -1,7 +1,6 @@
export default ({ activity }) => { export default ({ activity }) => {
const kaburiActivity = activity.filter(a => a.ch === "kaburi"); const count = activity.length;
const count = kaburiActivity.length; const time = activity
const time = kaburiActivity
.map(a => a.endTime - a.startTime) .map(a => a.endTime - a.startTime)
.reduce((a, c) => a + c, 0); .reduce((a, c) => a + c, 0);

View file

@ -9,7 +9,8 @@ export default class extends Component {
audioStream: null, audioStream: null,
left: null, left: null,
right: null, right: null,
activity: [] activity: [],
kaburiActivity: []
}; };
componentDidMount() { componentDidMount() {
@ -30,10 +31,9 @@ export default class extends Component {
const putKaburi = () => { const putKaburi = () => {
if (this.state.left !== null && this.state.right !== null) { if (this.state.left !== null && this.state.right !== null) {
this.setState({ this.setState({
activity: [ kaburiActivity: [
...this.state.activity, ...this.state.kaburiActivity,
{ {
ch: "kaburi",
startTime: Math.max(this.state.left, this.state.right), startTime: Math.max(this.state.left, this.state.right),
endTime: new Date().getTime() endTime: new Date().getTime()
} }
@ -111,7 +111,7 @@ export default class extends Component {
<dd>{this.state.right && "発話中..."}</dd> <dd>{this.state.right && "発話中..."}</dd>
</dl> </dl>
<Percentage activity={this.state.activity} /> <Percentage activity={this.state.activity} />
<Kaburi activity={this.state.activity} /> <Kaburi activity={this.state.kaburiActivity} />
</div> </div>
); );
} }