diff --git a/src/blocks/mrc_call_python_function.ts b/src/blocks/mrc_call_python_function.ts index a149c258..2d51f138 100644 --- a/src/blocks/mrc_call_python_function.ts +++ b/src/blocks/mrc_call_python_function.ts @@ -150,11 +150,6 @@ type CallPythonFunctionExtraState = { * The mechanism class name. Specified only if the function kind is INSTANCE_MECHANISM. */ mechanismClassName?: string, - - // The following fields allow Alan and Liz to load older projects. - // TODO(lizlooney): Remove these fields. - otherBlockId?: string, - mechanismBlockId?: string, } const CALL_PYTHON_FUNCTION = { @@ -303,7 +298,6 @@ const CALL_PYTHON_FUNCTION = { this: CallPythonFunctionBlock, extraState: CallPythonFunctionExtraState ): void { - fixOldExtraState(extraState); this.mrcFunctionKind = extraState.functionKind as FunctionKind; this.mrcReturnType = extraState.returnType; this.mrcArgs = []; @@ -1276,26 +1270,3 @@ function createFireEventBlock(event: storageModuleContent.Event): toolboxItems.B processArgs(args, extraState, inputs); return createBlock(extraState, fields, inputs); } - -// The following function allows Alan and Liz to load older projects. -// TODO(lizlooney): Remove this function. -function fixOldExtraState(extraState: CallPythonFunctionExtraState): void { - if (extraState.otherBlockId) { - switch (extraState.functionKind as FunctionKind) { - case FunctionKind.INSTANCE_WITHIN: - case FunctionKind.INSTANCE_ROBOT: - case FunctionKind.INSTANCE_MECHANISM: - extraState.methodId = extraState.otherBlockId; - break; - case FunctionKind.INSTANCE_COMPONENT: - extraState.componentId = extraState.otherBlockId; - break; - case FunctionKind.EVENT: - extraState.eventId = extraState.otherBlockId; - break; - } - } - if (extraState.mechanismBlockId) { - extraState.mechanismId = extraState.mechanismBlockId; - } -} diff --git a/src/blocks/mrc_event_handler.ts b/src/blocks/mrc_event_handler.ts index 3f26184f..648b89dd 100644 --- a/src/blocks/mrc_event_handler.ts +++ b/src/blocks/mrc_event_handler.ts @@ -73,11 +73,6 @@ export interface EventHandlerExtraState { * Specified only if the sender type is MECHANISM. */ mechanismId?: string, - - // The following fields allow Alan and Liz to load older projects. - // TODO(lizlooney): Remove these fields. - otherBlockId?: string, - mechanismBlockId?: string, } const EVENT_HANDLER = { @@ -126,7 +121,6 @@ const EVENT_HANDLER = { * Applies the given state to this block. */ loadExtraState(this: EventHandlerBlock, extraState: EventHandlerExtraState): void { - fixOldExtraState(extraState); this.mrcSenderType = extraState.senderType; this.mrcParameters = []; this.mrcEventId = extraState.eventId; @@ -508,14 +502,3 @@ export function renameMechanismName(workspace: Blockly.Workspace, mechanismId: s (block as EventHandlerBlock).renameMechanismName(mechanismId, newName); }); } - -// The following function allows Alan and Liz to load older projects. -// TODO(lizlooney): Remove this function. -function fixOldExtraState(extraState: EventHandlerExtraState): void { - if (extraState.otherBlockId) { - extraState.eventId = extraState.otherBlockId; - } - if (extraState.mechanismBlockId) { - extraState.mechanismId = extraState.mechanismBlockId; - } -} diff --git a/src/storage/client_side_storage.ts b/src/storage/client_side_storage.ts index 8a0493e8..e61ef120 100644 --- a/src/storage/client_side_storage.ts +++ b/src/storage/client_side_storage.ts @@ -20,8 +20,6 @@ */ import * as commonStorage from './common_storage'; -import * as storageModuleContent from './module_content'; -import * as storageNames from './names'; // Functions for saving blocks files to client side storage. @@ -58,62 +56,7 @@ export async function openClientSideStorage(): Promise { }; openRequest.onsuccess = () => { const db = openRequest.result; - fixOldModules(db).then(() => { - resolve(ClientSideStorage.create(db)); - }) - }; - }); -} - -// The following function allows Alan and Liz to load older projects. -// TODO(lizlooney): Remove this function. -async function fixOldModules(db: IDBDatabase): Promise { - return new Promise((resolve, reject) => { - const transaction = db.transaction([FILES_STORE_NAME], 'readwrite'); - transaction.oncomplete = () => { - resolve(); - }; - transaction.onabort = () => { - console.log('IndexedDB transaction aborted.'); - reject(new Error('IndexedDB transaction aborted.')); - }; - const filesObjectStore = transaction.objectStore(FILES_STORE_NAME); - const openCursorRequest = filesObjectStore.openCursor(); - openCursorRequest.onerror = () => { - console.log('IndexedDB openCursor request failed. openCursorRequest.error is...'); - console.log(openCursorRequest.error); - reject(new Error('IndexedDB openCursor request failed.')); - }; - openCursorRequest.onsuccess = () => { - const cursor = openCursorRequest.result; - if (cursor) { - const value = cursor.value; - const regexForOldModulePath = new RegExp('^([A-Z][A-Za-z0-9]*)/([A-Z][A-Za-z0-9]*).json$'); - const result = regexForOldModulePath.exec(value.path); - if (result) { - const oldModulePath = value.path; - const projectName = result[1]; - const className = result[2]; - const moduleType = storageModuleContent.parseModuleContentText(value.content).getModuleType(); - value.path = storageNames.makeModulePath(projectName, className, moduleType); - const putRequest = filesObjectStore.put(value); - putRequest.onerror = () => { - console.log('IndexedDB put request failed. putRequest.error is...'); - console.log(putRequest.error); - throw new Error('IndexedDB put request failed.'); - }; - const deleteRequest = filesObjectStore.delete(oldModulePath); - deleteRequest.onerror = () => { - console.log('IndexedDB delete request failed. deleteRequest.error is...'); - console.log(deleteRequest.error); - throw new Error('IndexedDB delete request failed.'); - }; - } - cursor.continue(); - } else { - // The cursor is done. We have finished reading all the files. - resolve(); - } + resolve(ClientSideStorage.create(db)); }; }); } diff --git a/src/storage/module_content.ts b/src/storage/module_content.ts index 8afab1ea..a41e4eb5 100644 --- a/src/storage/module_content.ts +++ b/src/storage/module_content.ts @@ -146,7 +146,6 @@ export function makeModuleContentText( export function parseModuleContentText(moduleContentText: string): ModuleContent { const parsedContent = JSON.parse(moduleContentText); - fixOldParsedContent(parsedContent); if (!('moduleType' in parsedContent) || !('moduleId' in parsedContent) || !('blocks' in parsedContent) || @@ -166,38 +165,6 @@ export function parseModuleContentText(moduleContentText: string): ModuleContent parsedContent.methods); } -// The following function allows Alan and Liz to load older projects. -// TODO(lizlooney): Remove this function. -function fixOldParsedContent(parsedContent: any): void { - if (!('moduleId' in parsedContent)) { - parsedContent.moduleId = ''; - } - parsedContent.mechanisms.forEach((mechanism: any) => { - if (!('mechanismId' in mechanism) && ('blockId' in mechanism)) { - mechanism.mechanismId = mechanism['blockId']; - delete mechanism['blockId']; - } - }); - parsedContent.components.forEach((component: any) => { - if (!('componentId' in component) && ('blockId' in component)) { - component.componentId = component['blockId']; - delete component['blockId']; - } - }); - parsedContent.events.forEach((event: any) => { - if (!('eventId' in event) && ('blockId' in event)) { - event.eventId = event['blockId']; - delete event['blockId']; - } - }); - parsedContent.methods.forEach((method: any) => { - if (!('methodId' in method) && ('blockId' in method)) { - method.methodId = method['blockId']; - delete method['blockId']; - } - }); -} - export class ModuleContent { constructor( private moduleType: storageModule.ModuleType,