Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/blocks/mrc_call_python_function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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;
}
}
17 changes: 0 additions & 17 deletions src/blocks/mrc_event_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
59 changes: 1 addition & 58 deletions src/storage/client_side_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -58,62 +56,7 @@ export async function openClientSideStorage(): Promise<commonStorage.Storage> {
};
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<void> {
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));
};
});
}
Expand Down
33 changes: 0 additions & 33 deletions src/storage/module_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand All @@ -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,
Expand Down