From 23aa8b52ab79981e5aa039c6c6e350a87d0d70c9 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Fri, 12 Aug 2016 16:30:17 +0200 Subject: [PATCH] Basic error mechanism in webplayer --- app/actions/webplayer.js | 52 +++++++++++--- app/components/elements/WebPlayer.jsx | 7 ++ app/locales/en-US/index.js | 1 + app/locales/fr-FR/index.js | 1 + .../messagesDescriptors/elements/WebPlayer.js | 5 ++ app/models/webplayer.js | 1 + app/reducers/webplayer.js | 67 ++++++++++++------- app/views/WebPlayer.jsx | 49 +++++++++----- scripts/extractTranslations.js | 2 + 9 files changed, 133 insertions(+), 52 deletions(-) diff --git a/app/actions/webplayer.js b/app/actions/webplayer.js index 5c4fd31..8a4a64f 100644 --- a/app/actions/webplayer.js +++ b/app/actions/webplayer.js @@ -4,6 +4,7 @@ // Other actions import { decrementRefCount, incrementRefCount } from "./entities"; +import { i18nRecord } from "../models/i18n"; export const PLAY_PAUSE = "PLAY_PAUSE"; @@ -251,8 +252,10 @@ export const TOGGLE_RANDOM = "TOGGLE_RANDOM"; * @return Dispatch a TOGGLE_RANDOM action. */ export function toggleRandom() { - return { - type: TOGGLE_RANDOM, + return (dispatch) => { + dispatch({ + type: TOGGLE_RANDOM, + }); }; } @@ -264,8 +267,10 @@ export const TOGGLE_REPEAT = "TOGGLE_REPEAT"; * @return Dispatch a TOGGLE_REPEAT action. */ export function toggleRepeat() { - return { - type: TOGGLE_REPEAT, + return (dispatch) => { + dispatch({ + type: TOGGLE_REPEAT, + }); }; } @@ -277,8 +282,10 @@ export const TOGGLE_MUTE = "TOGGLE_MUTE"; * @return Dispatch a TOGGLE_MUTE action. */ export function toggleMute() { - return { - type: TOGGLE_MUTE, + return (dispatch) => { + dispatch({ + type: TOGGLE_MUTE, + }); }; } @@ -292,10 +299,33 @@ export const SET_VOLUME = "SET_VOLUME"; * @return Dispatch a SET_VOLUME action. */ export function setVolume(volume) { - return { - type: SET_VOLUME, - payload: { - volume: volume, - }, + return (dispatch) => { + dispatch({ + type: SET_VOLUME, + payload: { + volume: volume, + }, + }); + }; +} + + +export const SET_ERROR = "SET_ERROR"; +/** + * Set an error in case a song is not in a supported format. + * + * @return Dispatch a SET_ERROR action. + */ +export function unsupportedMediaType() { + return (dispatch) => { + dispatch({ + type: SET_ERROR, + payload: { + error: new i18nRecord({ + id: "app.webplayer.unsupported", + values: {}, + }), + }, + }); }; } diff --git a/app/components/elements/WebPlayer.jsx b/app/components/elements/WebPlayer.jsx index 32d6374..014e26b 100644 --- a/app/components/elements/WebPlayer.jsx +++ b/app/components/elements/WebPlayer.jsx @@ -138,6 +138,12 @@ class WebPlayerCSSIntl extends Component { + { + this.props.error + ?

{this.props.error}

+ : null + } +