Skip to content

Commit 010f992

Browse files
committed
Reduce duplication of code
1 parent 6d5dcd5 commit 010f992

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/storage/project.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -316,24 +316,7 @@ export async function copyModuleInProject(
316316
moduleContent.changeIds();
317317
moduleContentText = moduleContent.getModuleContentText();
318318

319-
await storage.saveFile(newModulePath, moduleContentText);
320-
321-
// Update the project's mechanisms or opModes.
322-
const newModule = {
323-
modulePath: newModulePath,
324-
moduleType: oldModule.moduleType,
325-
projectName: project.projectName,
326-
className: newClassName
327-
};
328-
switch (oldModule.moduleType) {
329-
case storageModule.ModuleType.MECHANISM:
330-
project.mechanisms.push(newModule as storageModule.Mechanism);
331-
break;
332-
case storageModule.ModuleType.OPMODE:
333-
project.opModes.push(newModule as storageModule.OpMode);
334-
break;
335-
}
336-
await saveProjectInfo(storage, project.projectName);
319+
await addModuleToProject(storage, project, oldModule.moduleType, newClassName);
337320

338321
return newModulePath;
339322
}

0 commit comments

Comments
 (0)