Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function* subtitlesReloadSaga (_action) {
const scope = yield select(state => state.get('scope'));
const {selectedKey: key, availableOptions} = yield select(state => state.get('subtitles'));
if (key) {
/* Generate an initial item covering the entire recording (needed because
the editor works by splitting existing items at a specific position). */
let text = (availableOptions[key].text || '').trim();
if (!text) {
const data = yield select(state => state.getIn(['player', 'data']));
text = srtStringify([{start: 0, end: data.events[data.events.length - 1][0], text: ''}]);
}
yield put({type: scope.subtitlesLoadFromText, payload: {key, text}});
}
}
return state.update('subtitles', function (subtitles) {
const {selectedKey: key, availableOptions, items} = subtitles;
const text = srtStringify(items)
return clearNotify(update(subtitles, {availableOptions: {[key]: {text: {$set: text}}}}));
});
}