Skip to content

Commit a7069a8

Browse files
author
Ives van Hoorne
committed
Fix saving bug from mobx-state-tree
1 parent 1225531 commit a7069a8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/app/src/app/store/modules/editor/actions.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ export function updateSandboxPackage({ state }) {
6464

6565
export function setModuleSaved({ props, state }) {
6666
const changedModuleShortids = state.get('editor.changedModuleShortids');
67-
const indexToRemove = changedModuleShortids.indexOf(props.shortid);
67+
const newChangedModuleShortids = changedModuleShortids.filter(
68+
x => x !== props.shortid
69+
);
6870

69-
state.splice('editor.changedModuleShortids', indexToRemove, 1);
71+
state.set('editor.changedModuleShortids', newChangedModuleShortids);
7072
}
7173

7274
export function setModuleSavedCode({ props, state }) {
@@ -304,7 +306,12 @@ export function addChangedModule({ state, props }) {
304306
state.push('editor.changedModuleShortids', moduleShortid);
305307
}
306308
} else if (module.savedCode === module.code) {
307-
state.splice('editor.changedModuleShortids', moduleIndex, 1);
309+
state.set(
310+
'editor.changedModuleShortids',
311+
state
312+
.get('editor.changedModuleShortids')
313+
.filter(x => x !== moduleShortid)
314+
);
308315
}
309316
}
310317
}

packages/app/src/app/utils/prettify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function getMode(title: string) {
2121
}
2222

2323
if (/\.json$/.test(title)) {
24-
return 'json';
24+
return 'babylon';
2525
}
2626

2727
if (/\.css$/.test(title)) {

0 commit comments

Comments
 (0)