Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.updateSubtitles(subtitles, true).then(() => {
toastr.success(t('translate'));
});
})
this.updateSubtitles([], true).then(() => {
toastr.success(t('removeAll'));
});
}
this.updateSubtitles(subtitles, true).then(() => {
toastr.success(t('delete'));
});
}
downloadSubtitles() {
downloadFile(vttToUrl(arrToVtt(this.state.subtitles)), `${Date.now()}.vtt`);
toastr.success(t('download'));
}
check() {
const { index, subtitle } = this.state;
const { subtitles } = this.props;
const startTime = timeToSecond(subtitle.start);
const endTime = timeToSecond(subtitle.end);
const previous = subtitles[index - 1];
const next = subtitles[index + 1];
if (index !== -1) {
if (!checkTime(subtitle.start)) {
toastr.error(t('startTime'));
return false;
}
if (!checkTime(subtitle.end)) {
toastr.error(t('endTime'));
return false;
}
if (startTime >= endTime) {
toastr.error(t('greater'));
return false;
}
if ((previous && endTime < previous.startTime) || (next && startTime > next.endTime)) {
toastr.error(t('moveAcross'));
return false;
}
if (previous && startTime < previous.endTime) {
toastr.warning(t('overlaps'));
}
this.updateSubtitles(subtitles, true).then(() => {
toastr.success(t('delete'));
});
}
async getCanvasData() {
toastr.warning(t('waveformBuildStart'));
const canvasData = await wavesurfer({
height: timelineHeight,
videoUrl: this.props.videoUrl,
minPxPerSec: this.props.grid * 10,
maxCanvasWidth: (this.props.mainWidth - this.props.grid * 10),
});
if (canvasData.length) {
this.canvasData = canvasData;
const $waveform = this.$waveform.current;
const ctx = $waveform.getContext('2d');
ctx.clearRect(0, 0, $waveform.width, $waveform.height);
ctx.putImageData(this.canvasData[this.canvasIndex], this.props.grid * 5, 0);
toastr.success(t('waveformBuildEnd'));
}
}
if (this.state.subtitles.length <= 1000) {
this.inTranslation = true;
translate(this.state.subtitles, land, translator)
.then(subtitles => {
this.inTranslation = false;
this.updateSubtitles(subtitles, true).then(() => {
toastr.success(t('translate'));
});
})
.catch(error => {
toastr.error(error.message);
this.inTranslation = false;
throw error;
});
} else {
toastr.error(t('translateLenght'));
}
} else {
toastr.error(t('translateProgress'));
}
}
this.updateSubtitles(subtitles, true).then(() => {
toastr.success(t('removeEmpty'));
});
}
this.updateSubtitles(subtitles, true).then(() => {
toastr.success(t('translate'));
});
})