Skip to content

Commit 6b16df9

Browse files
christianalfoniCompuIves
authored andcommitted
Fix deleting module and directory (codesandbox#2403)
1 parent baea30a commit 6b16df9

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

packages/app/src/app/overmind/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Action, AsyncAction } from '.';
2-
import * as internalActions from './internalActions';
3-
import { withLoadApp } from './factories';
41
import {
52
NotificationType,
63
convertTypeToStatus,
74
} from '@codesandbox/common/lib/utils/notifications';
5+
import { Action, AsyncAction } from '.';
6+
import * as internalActions from './internalActions';
7+
import { withLoadApp } from './factories';
88

99
export const internal = internalActions;
1010

packages/app/src/app/overmind/namespaces/files/actions.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,9 @@ export const addedFileToSandbox: AsyncAction<{
225225
});
226226
};
227227

228-
export const deletedUploadedFile: AsyncAction<string> = async (
229-
{ state, effects },
230-
id
231-
) => {
228+
export const deletedUploadedFile: AsyncAction<{
229+
id: string;
230+
}> = async ({ state, effects }, { id }) => {
232231
try {
233232
await effects.api.deleteUploadedFile(id);
234233
state.uploadedFiles = null;
@@ -481,8 +480,10 @@ export const syncSandbox: AsyncAction<any[]> = async (
481480
}
482481
};
483482

484-
export const removeModule: AsyncAction<string> = withOwnedSandbox(
485-
async ({ state, effects, actions }, moduleShortid) => {
483+
export const removeModule: AsyncAction<{
484+
moduleShortid: string;
485+
}> = withOwnedSandbox(
486+
async ({ state, effects, actions }, { moduleShortid }) => {
486487
if (state.editor.currentModule.shortid === moduleShortid) {
487488
actions.editor.internal.setCurrentModule(state.editor.mainModule);
488489
}
@@ -504,10 +505,9 @@ export const removeModule: AsyncAction<string> = withOwnedSandbox(
504505
}
505506
);
506507

507-
export const removeDirectory: AsyncAction<string> = async (
508-
{ state },
509-
directoryShortid
510-
) => {
508+
export const removeDirectory: AsyncAction<{
509+
directoryShortid: string;
510+
}> = async ({ state }, { directoryShortid }) => {
511511
const sandbox = state.editor.currentSandbox;
512512
state.editor.currentModuleShortid = state.editor.mainModule.shortid;
513513
const directory = sandbox.directories.find(

packages/app/src/app/overmind/namespaces/live/liveMessageOperators.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ export const onModuleDeleted: Operator<
177177
return;
178178
}
179179
// Do not think this really works? Cause this would fork the sandbox
180-
actions.files.removeModule(data.moduleShortid);
180+
actions.files.removeModule({
181+
moduleShortid: data.moduleShortid,
182+
});
181183
});
182184

183185
export const onDirectoryCreated: Operator<
@@ -219,7 +221,9 @@ export const onDirectoryDeleted: Operator<
219221
}
220222
state.editor.currentModuleShortid = state.editor.mainModule.shortid;
221223
// Again, this does not work very well?
222-
actions.files.removeDirectory(data.directoryShortid);
224+
actions.files.removeDirectory({
225+
directoryShortid: data.directoryShortid,
226+
});
223227
});
224228

225229
export const onUserSelection: Operator<

0 commit comments

Comments
 (0)