Skip to content

Commit

Permalink
Inherit previous screen colors when adding a new screen
Browse files Browse the repository at this point in the history
fixes #63
  • Loading branch information
nurpax committed Aug 2, 2018
1 parent 1ce7ed1 commit cdcb5e5
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions app/redux/screens.js
Expand Up @@ -80,11 +80,40 @@ export const actions = {
}
},
newScreen: () => {
return {
type: ADD_SCREEN_AND_FRAMEBUF,
data: null
return (dispatch, getState) => {
const state = getState()
const index = state.screens.current
const fbidx = selectors.getScreens(state)[index]
const framebuf = selectors.getFramebufByIndex(state, fbidx)
let colors = null
if (framebuf !== null) {
colors = {
backgroundColor: framebuf.backgroundColor,
borderColor: framebuf.borderColor
}
}
dispatch({
type: ADD_SCREEN_AND_FRAMEBUF,
data: null
})
if (colors !== null) {
dispatch((dispatch, getState) => {
const state = getState()
const newScreenIdx = selectors.getCurrentScreenIndex(state)
const newFramebufIdx = selectors.getScreens(state)[newScreenIdx]
dispatch(Framebuffer.actions.setBackgroundColor(
colors.backgroundColor,
newFramebufIdx
))
dispatch(Framebuffer.actions.setBorderColor(
colors.borderColor,
newFramebufIdx
))
})
}
}
},

setCurrentScreenIndex: (index) => {
return {
type: SET_CURRENT_SCREEN_INDEX,
Expand Down

0 comments on commit cdcb5e5

Please sign in to comment.