|
20 | 20 | */ |
21 | 21 |
|
22 | 22 | import * as commonStorage from './common_storage'; |
| 23 | +import * as names from './names'; |
23 | 24 |
|
24 | 25 | // Functions for saving blocks modules to client side storage. |
25 | 26 |
|
@@ -148,8 +149,8 @@ class ClientSideStorage implements commonStorage.Storage { |
148 | 149 | const module: commonStorage.Module = { |
149 | 150 | modulePath: path, |
150 | 151 | moduleType: moduleType, |
151 | | - projectName: commonStorage.getProjectName(path), |
152 | | - className: commonStorage.getClassName(path), |
| 152 | + projectName: names.getProjectName(path), |
| 153 | + className: names.getClassName(path), |
153 | 154 | dateModifiedMillis: value.dateModifiedMillis, |
154 | 155 | } |
155 | 156 | if (moduleType === commonStorage.MODULE_TYPE_ROBOT) { |
@@ -243,8 +244,8 @@ class ClientSideStorage implements commonStorage.Storage { |
243 | 244 | } |
244 | 245 |
|
245 | 246 | async createProject(projectName: string, robotContent: string, opmodeContent : string): Promise<void> { |
246 | | - const modulePath = commonStorage.makeRobotPath(projectName); |
247 | | - const opmodePath = commonStorage.makeModulePath(projectName, commonStorage.CLASS_NAME_TELEOP); |
| 247 | + const modulePath = names.makeRobotPath(projectName); |
| 248 | + const opmodePath = names.makeModulePath(projectName, names.CLASS_NAME_TELEOP); |
248 | 249 |
|
249 | 250 | await this._saveModule(commonStorage.MODULE_TYPE_ROBOT, modulePath, robotContent); |
250 | 251 | await this._saveModule(commonStorage.MODULE_TYPE_OPMODE, opmodePath, opmodeContent); |
@@ -340,13 +341,13 @@ class ClientSideStorage implements commonStorage.Storage { |
340 | 341 | const value = cursor.value; |
341 | 342 | const path = value.path; |
342 | 343 | const moduleType = value.type; |
343 | | - if (commonStorage.getProjectName(path) === oldProjectName) { |
| 344 | + if (names.getProjectName(path) === oldProjectName) { |
344 | 345 | let newPath; |
345 | 346 | if (moduleType === commonStorage.MODULE_TYPE_ROBOT) { |
346 | | - newPath = commonStorage.makeRobotPath(newProjectName); |
| 347 | + newPath = names.makeRobotPath(newProjectName); |
347 | 348 | } else { |
348 | | - const className = commonStorage.getClassName(path); |
349 | | - newPath = commonStorage.makeModulePath(newProjectName, className); |
| 349 | + const className = names.getClassName(path); |
| 350 | + newPath = names.makeModulePath(newProjectName, className); |
350 | 351 | } |
351 | 352 | oldToNewModulePaths[path] = newPath; |
352 | 353 | } |
@@ -433,8 +434,8 @@ class ClientSideStorage implements commonStorage.Storage { |
433 | 434 | reject(new Error('IndexedDB transaction aborted.')); |
434 | 435 | }; |
435 | 436 | const modulesObjectStore = transaction.objectStore(MODULES_STORE_NAME); |
436 | | - const oldModulePath = commonStorage.makeModulePath(projectName, oldClassName); |
437 | | - const newModulePath = commonStorage.makeModulePath(projectName, newClassName); |
| 437 | + const oldModulePath = names.makeModulePath(projectName, oldClassName); |
| 438 | + const newModulePath = names.makeModulePath(projectName, newClassName); |
438 | 439 | const getRequest = modulesObjectStore.get(oldModulePath); |
439 | 440 | getRequest.onerror = () => { |
440 | 441 | console.log('IndexedDB get request failed. getRequest.error is...'); |
@@ -496,7 +497,7 @@ class ClientSideStorage implements commonStorage.Storage { |
496 | 497 | if (cursor) { |
497 | 498 | const value = cursor.value; |
498 | 499 | const path = value.path; |
499 | | - if (commonStorage.getProjectName(path) === projectName) { |
| 500 | + if (names.getProjectName(path) === projectName) { |
500 | 501 | modulePaths.push(path); |
501 | 502 | } |
502 | 503 | cursor.continue(); |
@@ -559,8 +560,8 @@ class ClientSideStorage implements commonStorage.Storage { |
559 | 560 | const cursor = openCursorRequest.result; |
560 | 561 | if (cursor) { |
561 | 562 | const value = cursor.value; |
562 | | - if (commonStorage.getProjectName(value.path) === projectName) { |
563 | | - const className = commonStorage.getClassName(value.path); |
| 563 | + if (names.getProjectName(value.path) === projectName) { |
| 564 | + const className = names.getClassName(value.path); |
564 | 565 | classNameToModuleContentText[className] = value.content; |
565 | 566 | } |
566 | 567 | cursor.continue(); |
@@ -602,7 +603,7 @@ class ClientSideStorage implements commonStorage.Storage { |
602 | 603 | for (const className in classNameToModuleType) { |
603 | 604 | const moduleType = classNameToModuleType[className]; |
604 | 605 | const moduleContentText = classNameToModuleContentText[className]; |
605 | | - const modulePath = commonStorage.makeModulePath(projectName, className); |
| 606 | + const modulePath = names.makeModulePath(projectName, className); |
606 | 607 | const getRequest = modulesObjectStore.get(modulePath); |
607 | 608 | getRequest.onerror = () => { |
608 | 609 | console.log('IndexedDB get request failed. getRequest.error is...'); |
|
0 commit comments