Skip to content

Commit 414a830

Browse files
author
sakal
committed
fix: response audio.play
Signed-off-by: sakal <[email protected]>
1 parent 8d1d105 commit 414a830

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/redux-core/actions/stations.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const audioListener = (prevAudio, station, dispatch) => {
3535
const handleLoaded = () => {
3636
localStorage.setItem(cacheConfig.station.key, JSON.stringify(station));
3737
prevAudio.pause();
38-
audio.play();
39-
resolve({...station, audio});
38+
audio.play()
39+
.then(() => resolve({...station, audio}))
40+
.catch(() => reject());
4041
clearTimeout(timerId);
4142
};
4243

@@ -49,7 +50,10 @@ const audioListener = (prevAudio, station, dispatch) => {
4950
export const setCurrentStation = station => (dispatch, getState) => {
5051
const prevAudio = getState().stations.station.audio;
5152

52-
!station.uid && prevAudio.pause();
53+
!station.uid && (
54+
prevAudio.pause(),
55+
localStorage.setItem(cacheConfig.station.key, JSON.stringify(station))
56+
);
5357

5458
delete station.audio;
5559

src/redux-core/store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import promise from 'redux-promise-middleware';
66

77
import rootReducer from './reducers';
88

9-
const middleware = applyMiddleware(promise(), thunk);
9+
const middleware = applyMiddleware(promise(), thunk, logger);
1010

1111
const store = createStore(rootReducer, middleware);
1212

0 commit comments

Comments
 (0)