Skip to content

Commit

Permalink
fix: Crash, when loading presets into livemode
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSusa committed Sep 20, 2020
1 parent 9d419df commit 626c8f0
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages": [
"packages/*"
],
"version": "1.3.39-alpha.10"
"version": "1.3.39-alpha.12"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "midi-bricks-mono",
"version": "1.3.39-alpha.10",
"version": "1.3.39-alpha.12",
"private": false,
"license": "MIT",
"repository": "https://github.com/TimSusa/midi-bricks-mono.git",
Expand Down
2 changes: 1 addition & 1 deletion packages/midi-bricks-doc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "midi-bricks-doc",
"version": "1.3.39-alpha.10",
"version": "1.3.39-alpha.12",
"private": true,
"description": "Documentation for midi-bricks",
"author": "TimSusa <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion packages/midi-bricks-electron/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "midi-bricks-electron",
"productName": "MIDI-Bricks",
"version": "1.3.39-alpha.10",
"version": "1.3.39-alpha.12",
"main": "./app/electron.js",
"homepage": ".",
"repository": "https://github.com/TimSusa/midi-bricks-mono.git",
Expand Down
2 changes: 1 addition & 1 deletion packages/midi-bricks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "midi-bricks",
"version": "1.3.39-alpha.10",
"version": "1.3.39-alpha.12",
"private": false,
"homepage": "https://midi-bricks.timsusa.now.sh",
"main": "./src/index.js",
Expand Down
34 changes: 11 additions & 23 deletions packages/midi-bricks/src/components/drawer-list/DrawerListCmp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Actions as ViewSettingsActions } from '../../global-state/actions/view-
import { useSelector, useDispatch } from 'react-redux'

const version = process.env.REACT_APP_VERSION || 'dev'
const { togglePage, saveFile, deleteFooterPages, deleteAll } = {
const { togglePage, saveFile } = {
...MidiSliderActions,
...ViewSettingsActions
}
Expand Down Expand Up @@ -125,16 +125,12 @@ function DrawerListCmp(props) {
<List>
{process.env.REACT_APP_IS_WEB_MODE === 'true' ? (
<ListItemLoadFileOnWeb
onFileChange={(e) =>
handleFileChange(e, thunkLoadFile, onFileChange)
}
onFileChange={handleFileChange}
iconColor={classes.iconColor}
/>
) : (
<ListItemLoadFileOnElectron
onFileChange={(e) =>
handleFileChange(e, thunkLoadFile, onFileChange)
}
onFileChange={handleFileChange}
iconColor={classes.iconColor}
/>
)}
Expand All @@ -161,9 +157,7 @@ function DrawerListCmp(props) {
</ListItem>
) : (
<ListItemSaveFileOnElectron
onFileChange={(e) =>
handleFileChange(e, thunkLoadFile, onFileChange)
}
onFileChange={handleFileChange}
iconColor={classes.iconColor}
/>
)}
Expand All @@ -178,13 +172,7 @@ function DrawerListCmp(props) {
sliderEntry={{
i: 'me'
}}
onAction={handleResetSliders.bind(
this,
thunkDelete,
handleResetSlidersTmp,
deleteAll,
deleteFooterPages
)}
onAction={handleResetSliders}
onClose={setOpen}
/>
</ListItem>
Expand All @@ -198,13 +186,13 @@ function DrawerListCmp(props) {
<Divider />
</React.Fragment>
)
function handleResetSliders(thunkDeletet, cb) {
cb()
return dispatch(thunkDeletet('all'))
function handleResetSliders() {
handleResetSlidersTmp()
return dispatch(thunkDelete('all'))
}
async function handleFileChange(content, thunkLoadFilet, cb) {
await thunkLoadFilet(content.content, content.presetName)
cb(content.content, content.presetName)
async function handleFileChange(content) {
await dispatch(thunkLoadFile(content.content, content.presetName))
onFileChange(content.content, content.presetName)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Actions as viewSettingsActions } from '../view-settings'
import { Actions as pageActions } from '../pages'
import { initApp } from '../init'
import { initId } from '../../reducers/slider-list'

import localforage from 'localforage'
const { loadFile, deleteAll } = sliderListActions
const { updateViewSettings, setLastFocusedPage, deleteFooterPages } = viewSettingsActions
const { updatePages } = pageActions
Expand All @@ -24,6 +24,7 @@ export function thunkLoadFile(content, presetName) {

if (pages) {
promArray.push(dispatch(updatePages({ pages })))
await localforage.setItem('pages', pages)
} else {
const {
pages: oldPages,
Expand Down
12 changes: 11 additions & 1 deletion packages/midi-bricks/src/global-state/reducers/slider-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,17 @@ export const sliders = {
const tmpFilterStore = {
version,
pages,
viewSettings,
viewSettings:
{
...viewSettings,
isLiveMode: true,
isSettingsDialogMode: false,
isLayoutMode: false,
isCompactHorz: false,
isSettingsMode: false,
isMidiLearnMode: false,
isAutoArrangeMode: false
},
sliders: tmpSliders
}
const content = JSON.stringify(tmpFilterStore)
Expand Down

0 comments on commit 626c8f0

Please sign in to comment.