Skip to content

Commit

Permalink
fix: Full load/save all viewsettings from preset files
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSusa committed May 3, 2019
1 parent 0dfa430 commit 89ef519
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
19 changes: 5 additions & 14 deletions packages/midi-bricks-electron/public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,8 @@ function onSaveFileDialog(event, arg) {
defaultPath: app.getPath('userData'),
filters: [
{
name: 'json',
extensions: ['json']
},
{
name: 'javascript',
extensions: ['js']
name: 'midi-bricks-preset',
extensions: ['json', 'js']
}
]
},
Expand Down Expand Up @@ -222,12 +218,8 @@ function onOpenFileDialog(event, arg) {
properties: ['openFile'],
filters: [
{
name: 'javascript',
extensions: ['js']
},
{
name: 'json',
extensions: ['json']
name: 'midi-bricks-preset',
extensions: ['json', 'js']
}
]
},
Expand All @@ -243,8 +235,7 @@ function onOpenFileDialog(event, arg) {
appSettings = persistAppSettings(arg)
event.sender.send('open-file-dialog-reply', stuff)
log.info(
'Object loaded: ',
stuff.content.viewSettings || 'nothing found'
'Object loaded: '
)
return data
},
Expand Down
14 changes: 9 additions & 5 deletions packages/midi-bricks/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ App.propTypes = {
initApp: PropTypes.func
}

console.log('we have a new app in here')
function App(props) {
const classes = makeStyles(styles, { withTheme: true })()
const { actions = {}, initApp = () => {} } = props
Expand Down Expand Up @@ -91,8 +90,8 @@ async function onFileChange(
actions.deleteFooterPages()
window.localStorage.clear()

// Prepare foooterpages flush
actions.loadFile({ presetName, content })
// will load content to slider-list-reducer
actions.loadFile({ presetName, content })

const {
viewSettings,
Expand All @@ -113,11 +112,16 @@ async function onFileChange(
}
}
}
sliderList &&
actions.updateViewSettings({

// Will load content to view-settings-reducer
sliderList && Array.isArray(sliderList)
? actions.updateViewSettings({
viewSettings: { ...viewSettings, availableDrivers: drivers },
sliderList: sliderList
})
: actions.updateViewSettings({
viewSettings: { ...viewSettings, availableDrivers: drivers }
})
await initApp()
actions.togglePage({
pageType: PAGE_TYPES.GLOBAL_MODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ValueInput.propTypes = {
name: PropTypes.string,
onChange: PropTypes.func,
toolTip: PropTypes.string,
value: PropTypes.number,
value: PropTypes.string,
isDisabled: PropTypes.bool
}

Expand Down
5 changes: 1 addition & 4 deletions packages/midi-bricks/src/reducers/slider-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export const reducers = {
const {
payload: {
presetName,
content: { viewSettings, sliders: { sliderList: sliderListOld = [] } = {} } = {}
content: { sliders: { sliderList: sliderListOld = [] } = {} } = {}
} = {}
} = action

Expand Down Expand Up @@ -502,9 +502,6 @@ export const reducers = {
sliderList,
presetName,
sliderListBackup: sliderList,
viewSettings: {
...viewSettings
}
}
},
[ActionTypeSliderList.CHANGE_LIST_ORDER](state, action) {
Expand Down
5 changes: 3 additions & 2 deletions packages/midi-bricks/src/reducers/view-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const reducers = {
[ActionTypeViewSettings.UPDATE_VIEW_SETTINGS](state = initState, action) {
const {
sliderList,
viewSettings,
viewSettings: { availableDrivers } = {}
} = action.payload

Expand All @@ -159,11 +160,11 @@ export const reducers = {
const newPages = oldPages && oldPages.length > 0 ? oldPages : extractedPages
let footerState = null
if (newItemToTake) {
footerState = Object.assign({}, state, {
footerState = Object.assign({}, state, viewSettings, {
footerPages: [...newPages, newItemToTake]
})
} else {
footerState = Object.assign({}, state, {
footerState = Object.assign({}, state, viewSettings, {
footerPages: newPages
})
}
Expand Down

0 comments on commit 89ef519

Please sign in to comment.