diff --git a/src/store/effects/player.js b/src/store/effects/player.js index a338f9b37..2e6d45a88 100644 --- a/src/store/effects/player.js +++ b/src/store/effects/player.js @@ -47,7 +47,6 @@ export default mediaPlayer => (store, action) => { player && player.actions.setPlaytime(millisecondsToSeconds(action.payload)) break case 'SET_VOLUME': - console.log(player) player && player.actions.setVolume(action.payload) break case 'SET_RATE': diff --git a/src/store/effects/transcripts/active.test.js b/src/store/effects/transcripts/active.test.js index fe0aafd12..d6d9199e1 100644 --- a/src/store/effects/transcripts/active.test.js +++ b/src/store/effects/transcripts/active.test.js @@ -45,7 +45,7 @@ playtimeTypes.forEach(type => { activeEffect(store, { type: 'SET_PLAYTIME', - payload: 350 + payload: 350000 }) t.deepEqual(store.dispatch.getCall(1).args[0], { @@ -62,7 +62,7 @@ playtimeTypes.forEach(type => { activeEffect(store, { type: 'SET_PLAYTIME', - payload: 700 + payload: 700000 }) t.is(store.dispatch.getCalls().length, 1) @@ -126,12 +126,12 @@ test.cb(`transcripts - active: calls interval search debounced with payload on S activeEffect(store, { type: 'SIMULATE_PLAYTIME', - payload: 350 + payload: 350000 }) activeEffect(store, { type: 'SIMULATE_PLAYTIME', - payload: 350 + payload: 350000 }) }) diff --git a/src/store/effects/transcripts/fetch.js b/src/store/effects/transcripts/fetch.js index e06d6c39b..4454cc560 100644 --- a/src/store/effects/transcripts/fetch.js +++ b/src/store/effects/transcripts/fetch.js @@ -1,18 +1,20 @@ import actions from 'store/actions' -import { get, last, find } from 'lodash' +import { get, last, find, isNumber } from 'lodash' import { compose, map, concat, orderBy, reduce } from 'lodash/fp' import request from 'utils/request' -import { toPlayerTime } from 'utils/time' +import { toPlayerTime, secondsToMilliseconds } from 'utils/time' + +const transformTime = time => isNumber(time) ? secondsToMilliseconds(time) : toPlayerTime(time) const transformTranscript = reduce((transcripts, chunk) => { const lastChunk = last(transcripts) if (lastChunk && lastChunk.speaker && lastChunk.speaker === chunk.speaker) { - transcripts[transcripts.length - 1].end = toPlayerTime(chunk.end) + transcripts[transcripts.length - 1].end = transformTime(chunk.end) transcripts[transcripts.length - 1].texts.push({ - start: toPlayerTime(chunk.start), - end: toPlayerTime(chunk.end), + start: transformTime(chunk.start), + end: transformTime(chunk.end), text: chunk.text }) @@ -23,13 +25,13 @@ const transformTranscript = reduce((transcripts, chunk) => { ...transcripts, { type: 'transcript', - start: toPlayerTime(chunk.start), - end: toPlayerTime(chunk.end), + start: transformTime(chunk.start), + end: transformTime(chunk.end), speaker: chunk.speaker, texts: [ { - start: toPlayerTime(chunk.start), - end: toPlayerTime(chunk.end), + start: transformTime(chunk.start), + end: transformTime(chunk.end), text: chunk.text } ] @@ -41,7 +43,7 @@ const transformChapters = (chapter, index) => ({ ...chapter, type: 'chapter', index: index + 1, - start: toPlayerTime(chapter.start) + start: transformTime(chapter.start) }) const mapSpeakers = speakers => diff --git a/src/store/effects/transcripts/fixtures.js b/src/store/effects/transcripts/fixtures.js index c4df38dae..336dc7bfd 100644 --- a/src/store/effects/transcripts/fixtures.js +++ b/src/store/effects/transcripts/fixtures.js @@ -71,64 +71,67 @@ export const timeline = [ { type: 'transcript', start: 0, - end: 200, + end: 200000, speaker: { + id: 'speaker-1', name: 'Speaker One', avatar: 'http://avatar/speaker/one' }, texts: [ { start: 0, - end: 100, + end: 100000, text: 'fooo' }, { - start: 100, - end: 200, + start: 100000, + end: 200000, text: 'blaa' } ] }, { title: 'Chapter Two', - start: 200, + start: 200000, type: 'chapter', index: 2 }, { type: 'transcript', - start: 200, - end: 300, + start: 200000, + end: 300000, speaker: { + id: 'speaker-2', name: 'Speaker Two', avatar: 'http://avatar/speaker/two' }, texts: [ { - start: 200, - end: 300, + start: 200000, + end: 300000, text: 'bar' } ] }, { title: 'Chapter Three', - start: 250, + start: 250000, type: 'chapter', index: 3 }, { type: 'transcript', - start: 300, - end: 400, + start: 300000, + end: 400000, speaker: { + id: 'speaker-3', name: 'Speaker Three', avatar: 'http://avatar/speaker/three' }, texts: [ { - start: 300, - end: 400, + start: 300000, + end: 400000, text: 'baz' } ] diff --git a/src/utils/time.js b/src/utils/time.js index 04cccea7b..54184947a 100644 --- a/src/utils/time.js +++ b/src/utils/time.js @@ -98,7 +98,7 @@ export const parseMilliseconds = (time = '0') => { // Transforms a h:mm:ss.f or mm:ss.ffff or ss time to milliseconds export const toPlayerTime = (time = '0') => { if (isNumber(time)) { - return secondsToMilliseconds(time) + return time } time = time || '0'