Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
feat(last-action): Add last action reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-heimbuch committed Oct 19, 2017
1 parent b199284 commit 1f35ca0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
34 changes: 18 additions & 16 deletions src/embed/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ const renderPlayer = anchor => player => {
.then(getPodloveStore)
}

// Config Node
const configNode = (config = {}) =>
Bluebird.resolve(config)
const mergeConfig = (episode) =>
Bluebird.resolve(episode)
// If the config is a string, lets assume that this will point to the remote config json
.then(config => isString(config) ? requestConfig(config) : config)
// Load parameters from url
.then(config => Object.assign({}, config, params))
// Finally return the node
.then(config => tag('script', `window.PODLOVE = ${JSON.stringify(config)}`))

// Config Node
const configNode = (config = {}) => tag('script', `window.PODLOVE = ${JSON.stringify(config)}`)

// Player Logic
const styleBundle = config => tag('link', '', {rel: 'stylesheet', href: `${get(config.reference, 'base', '.')}/style.css`})
Expand All @@ -108,16 +108,18 @@ const dynamicResizer = tag('script', iframeResizerContentWindow)
const playerEntry = tag('PodlovePlayer')

// Bootstrap
window.podlovePlayer = (selector, config) => {
window.podlovePlayer = (selector, episode) => {
const anchor = typeof selector === 'string' ? head(findNode(selector)) : selector
return Bluebird.all([
playerEntry,
configNode(config),
styleBundle(config),
vendorBundle(config),
appBundle(config),
dynamicResizer
])
.then(result => result.join(''))
.then(renderPlayer(anchor))

return mergeConfig(episode)
.then(config => Bluebird.all([
playerEntry,
configNode(config),
styleBundle(config),
vendorBundle(config),
appBundle(config),
dynamicResizer
]))
.then(result => result.join(''))
.then(renderPlayer(anchor))
}
4 changes: 3 additions & 1 deletion src/store/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as show from './show'
import * as episode from './episode'
import * as download from './download'
import * as contributors from './contributors'
import * as lastAction from './last-action'

export default combineReducers({
...init,
Expand All @@ -33,5 +34,6 @@ export default combineReducers({
...show,
...episode,
...download,
...contributors
...contributors,
...lastAction
})
5 changes: 5 additions & 0 deletions src/store/reducers/last-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const lastAction = (state = null, action) => action

export {
lastAction
}

0 comments on commit 1f35ca0

Please sign in to comment.