Skip to content

Commit a231baa

Browse files
author
Ives van Hoorne
committed
Fix deleting module code on fork
1 parent f6bce3b commit a231baa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/app/store/entities/sandboxes/actions.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,19 @@ const forkSandbox = (id: string) => async (
123123
data.currentModule = currentSandbox.currentModule;
124124
}
125125
data.forked = true;
126+
127+
// Save the unsaved modules
128+
const oldModules = modulesSelector(getState());
126129
await dispatch(normalizeResult(entity, data));
127130

128131
dispatch(push(sandboxUrl(data)));
129132

133+
// Set the code for the new modules from the old modules
134+
currentSandbox.modules
135+
.map(mid => oldModules[mid])
136+
.filter(m => m.isNotSynced)
137+
.forEach(m => dispatch(moduleActions.setCode(m.id, m.code)));
138+
130139
dispatch(notificationActions.addNotification('Forked sandbox!', 'success'));
131140

132141
return data;

0 commit comments

Comments
 (0)