Skip to content

Commit 5daa8f4

Browse files
committed
renaming progress to currentTime
1 parent 1ce918b commit 5daa8f4

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

app/actions/setCurrentTime.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
export const SET_CURRENT_TIME = 'SET_CURRENT_TIME';
4+
5+
export function setCurrentTime(currentTime) {
6+
return {
7+
type: SET_CURRENT_TIME,
8+
currentTime: currentTime
9+
};
10+
}

app/actions/setProgress.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/reducers/playback.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import { IS_PLAYING } from '../actions/isPlaying';
44
import { HAS_STOPPED } from '../actions/hasStopped';
55
import { SET_VOLUME } from '../actions/setVolume';
6-
import { SET_PROGRESS } from '../actions/setProgress';
6+
import { SET_CURRENT_TIME } from '../actions/setCurrentTime';
77
import { SET_DURATION } from '../actions/setDuration';
88

99
const initialState = {
1010
isPlaying: false,
1111
hasStopped: true,
1212
volume: 50,
13-
progress: 0,
13+
currentTime: 0,
1414
duration: 0
1515
};
1616

@@ -44,9 +44,9 @@ function setVolumeState(volume) {
4444
};
4545
}
4646

47-
function setProgressState(progress) {
47+
function setCurrentTimeState(currentTime) {
4848
return {
49-
progress: progress
49+
currentTime: currentTime
5050
};
5151
}
5252

@@ -64,8 +64,8 @@ export function playbackReducer(state = initialState, action) {
6464
return Object.assign({}, state, setHasStoppedState(action.hasStopped));
6565
case SET_VOLUME :
6666
return Object.assign({}, state, setVolumeState(action.volume));
67-
case SET_PROGRESS :
68-
return Object.assign({}, state, setProgressState(action.progress));
67+
case SET_CURRENT_TIME :
68+
return Object.assign({}, state, setCurrentTimeState(action.currentTime));
6969
case SET_DURATION :
7070
return Object.assign({}, state, setDurationState(action.duration));
7171
default:

app/store/mapStoreToPlayer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
import { hasStopped } from '../actions/hasStopped';
4-
import { setProgress } from '../actions/setProgress';
4+
import { setCurrentTime } from '../actions/setCurrentTime';
55
import { setDuration } from '../actions/setDuration';
66

77
function setupPlayer(player) {
@@ -26,7 +26,7 @@ function setupDispatch(store, player) {
2626
store.dispatch(setDuration(player.duration));
2727

2828
player.addEventListener('ended', () => store.dispatch(hasStopped(true)));
29-
player.addEventListener('timeupdate', () => store.dispatch(setProgress(player.currentTime)));
29+
player.addEventListener('timeupdate', () => store.dispatch(setCurrentTime(player.currentTime)));
3030
}
3131

3232
function isPlayingChanged(previousState, currentState) {

test/actions/setCurrentTime.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
import assert from 'assert';
4+
import { SET_CURRENT_TIME, setCurrentTime } from '../../app/actions/setCurrentTime';
5+
6+
describe('setCurrentTime', () => {
7+
it('returns an object with the currentTime: {NUMBER}', () => {
8+
const action = setCurrentTime(50);
9+
10+
assert.equal(action.type, SET_CURRENT_TIME);
11+
assert.equal(action.currentTime, 50);
12+
});
13+
});

test/actions/setProgress.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/reducers/playback.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import assert from 'assert';
44
import { IS_PLAYING } from '../../app/actions/isPlaying';
55
import { HAS_STOPPED } from '../../app/actions/hasStopped';
66
import { SET_VOLUME } from '../../app/actions/setVolume';
7-
import { SET_PROGRESS } from '../../app/actions/setProgress';
7+
import { SET_CURRENT_TIME } from '../../app/actions/setCurrentTime';
88
import { SET_DURATION } from '../../app/actions/setDuration';
99
import { playbackReducer } from '../../app/reducers/playback';
1010

@@ -74,18 +74,18 @@ describe('playbackState', () => {
7474
});
7575
});
7676

77-
describe('progress property', () => {
77+
describe('currentTime property', () => {
7878
it('defaults to 0', () => {
79-
assert.strictEqual(playbackReducer(undefined, '').progress, 0);
79+
assert.strictEqual(playbackReducer(undefined, '').currentTime, 0);
8080
});
8181

82-
it('sets {progress: 75} when action.progress is 75', () => {
82+
it('sets {currentTime: 75} when action.currentTime is 75', () => {
8383
const state = playbackReducer(undefined, {
84-
type: SET_PROGRESS,
85-
progress: 75
84+
type: SET_CURRENT_TIME,
85+
currentTime: 75
8686
});
8787

88-
assert.strictEqual(state.progress, 75);
88+
assert.strictEqual(state.currentTime, 75);
8989
});
9090
});
9191

test/store/mapStoreToPlayer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import _ from 'lodash';
77
import configureStore from '../../app/store/configurePlayerStore';
88
import mapStoreToPlayer from '../../app/store/mapStoreToPlayer';
99
import { HAS_STOPPED } from '../../app/actions/hasStopped';
10-
import { SET_PROGRESS } from '../../app/actions/setProgress';
10+
import { SET_CURRENT_TIME } from '../../app/actions/setCurrentTime';
1111
import { SET_DURATION } from '../../app/actions/setDuration';
1212

1313
const store = configureStore();
@@ -140,14 +140,14 @@ describe('mapStoreToPlayer', () => {
140140
unsubscribe();
141141
});
142142

143-
it('dispatched SET_PROGRESS: {NUMBER} when the timeupdate event is triggered', () => {
143+
it('dispatched SET_CURRENT_TIME: {NUMBER} when the timeupdate event is triggered', () => {
144144
const player = setupPlayer({
145145
currentTime: 75
146146
});
147147
const unsubscribe = mapStoreToPlayer(store, player);
148148
const expectedCallArgs = {
149-
type: SET_PROGRESS,
150-
progress: 75
149+
type: SET_CURRENT_TIME,
150+
currentTime: 75
151151
};
152152

153153
player.timeupdate();

0 commit comments

Comments
 (0)