Skip to content

Commit 439b886

Browse files
authored
Remove temporary code. (#213)
1 parent f1dc222 commit 439b886

File tree

4 files changed

+1
-137
lines changed

4 files changed

+1
-137
lines changed

src/blocks/mrc_call_python_function.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ type CallPythonFunctionExtraState = {
150150
* The mechanism class name. Specified only if the function kind is INSTANCE_MECHANISM.
151151
*/
152152
mechanismClassName?: string,
153-
154-
// The following fields allow Alan and Liz to load older projects.
155-
// TODO(lizlooney): Remove these fields.
156-
otherBlockId?: string,
157-
mechanismBlockId?: string,
158153
}
159154

160155
const CALL_PYTHON_FUNCTION = {
@@ -303,7 +298,6 @@ const CALL_PYTHON_FUNCTION = {
303298
this: CallPythonFunctionBlock,
304299
extraState: CallPythonFunctionExtraState
305300
): void {
306-
fixOldExtraState(extraState);
307301
this.mrcFunctionKind = extraState.functionKind as FunctionKind;
308302
this.mrcReturnType = extraState.returnType;
309303
this.mrcArgs = [];
@@ -1276,26 +1270,3 @@ function createFireEventBlock(event: storageModuleContent.Event): toolboxItems.B
12761270
processArgs(args, extraState, inputs);
12771271
return createBlock(extraState, fields, inputs);
12781272
}
1279-
1280-
// The following function allows Alan and Liz to load older projects.
1281-
// TODO(lizlooney): Remove this function.
1282-
function fixOldExtraState(extraState: CallPythonFunctionExtraState): void {
1283-
if (extraState.otherBlockId) {
1284-
switch (extraState.functionKind as FunctionKind) {
1285-
case FunctionKind.INSTANCE_WITHIN:
1286-
case FunctionKind.INSTANCE_ROBOT:
1287-
case FunctionKind.INSTANCE_MECHANISM:
1288-
extraState.methodId = extraState.otherBlockId;
1289-
break;
1290-
case FunctionKind.INSTANCE_COMPONENT:
1291-
extraState.componentId = extraState.otherBlockId;
1292-
break;
1293-
case FunctionKind.EVENT:
1294-
extraState.eventId = extraState.otherBlockId;
1295-
break;
1296-
}
1297-
}
1298-
if (extraState.mechanismBlockId) {
1299-
extraState.mechanismId = extraState.mechanismBlockId;
1300-
}
1301-
}

src/blocks/mrc_event_handler.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ export interface EventHandlerExtraState {
7373
* Specified only if the sender type is MECHANISM.
7474
*/
7575
mechanismId?: string,
76-
77-
// The following fields allow Alan and Liz to load older projects.
78-
// TODO(lizlooney): Remove these fields.
79-
otherBlockId?: string,
80-
mechanismBlockId?: string,
8176
}
8277

8378
const EVENT_HANDLER = {
@@ -126,7 +121,6 @@ const EVENT_HANDLER = {
126121
* Applies the given state to this block.
127122
*/
128123
loadExtraState(this: EventHandlerBlock, extraState: EventHandlerExtraState): void {
129-
fixOldExtraState(extraState);
130124
this.mrcSenderType = extraState.senderType;
131125
this.mrcParameters = [];
132126
this.mrcEventId = extraState.eventId;
@@ -508,14 +502,3 @@ export function renameMechanismName(workspace: Blockly.Workspace, mechanismId: s
508502
(block as EventHandlerBlock).renameMechanismName(mechanismId, newName);
509503
});
510504
}
511-
512-
// The following function allows Alan and Liz to load older projects.
513-
// TODO(lizlooney): Remove this function.
514-
function fixOldExtraState(extraState: EventHandlerExtraState): void {
515-
if (extraState.otherBlockId) {
516-
extraState.eventId = extraState.otherBlockId;
517-
}
518-
if (extraState.mechanismBlockId) {
519-
extraState.mechanismId = extraState.mechanismBlockId;
520-
}
521-
}

src/storage/client_side_storage.ts

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
*/
2121

2222
import * as commonStorage from './common_storage';
23-
import * as storageModuleContent from './module_content';
24-
import * as storageNames from './names';
2523

2624
// Functions for saving blocks files to client side storage.
2725

@@ -58,62 +56,7 @@ export async function openClientSideStorage(): Promise<commonStorage.Storage> {
5856
};
5957
openRequest.onsuccess = () => {
6058
const db = openRequest.result;
61-
fixOldModules(db).then(() => {
62-
resolve(ClientSideStorage.create(db));
63-
})
64-
};
65-
});
66-
}
67-
68-
// The following function allows Alan and Liz to load older projects.
69-
// TODO(lizlooney): Remove this function.
70-
async function fixOldModules(db: IDBDatabase): Promise<void> {
71-
return new Promise((resolve, reject) => {
72-
const transaction = db.transaction([FILES_STORE_NAME], 'readwrite');
73-
transaction.oncomplete = () => {
74-
resolve();
75-
};
76-
transaction.onabort = () => {
77-
console.log('IndexedDB transaction aborted.');
78-
reject(new Error('IndexedDB transaction aborted.'));
79-
};
80-
const filesObjectStore = transaction.objectStore(FILES_STORE_NAME);
81-
const openCursorRequest = filesObjectStore.openCursor();
82-
openCursorRequest.onerror = () => {
83-
console.log('IndexedDB openCursor request failed. openCursorRequest.error is...');
84-
console.log(openCursorRequest.error);
85-
reject(new Error('IndexedDB openCursor request failed.'));
86-
};
87-
openCursorRequest.onsuccess = () => {
88-
const cursor = openCursorRequest.result;
89-
if (cursor) {
90-
const value = cursor.value;
91-
const regexForOldModulePath = new RegExp('^([A-Z][A-Za-z0-9]*)/([A-Z][A-Za-z0-9]*).json$');
92-
const result = regexForOldModulePath.exec(value.path);
93-
if (result) {
94-
const oldModulePath = value.path;
95-
const projectName = result[1];
96-
const className = result[2];
97-
const moduleType = storageModuleContent.parseModuleContentText(value.content).getModuleType();
98-
value.path = storageNames.makeModulePath(projectName, className, moduleType);
99-
const putRequest = filesObjectStore.put(value);
100-
putRequest.onerror = () => {
101-
console.log('IndexedDB put request failed. putRequest.error is...');
102-
console.log(putRequest.error);
103-
throw new Error('IndexedDB put request failed.');
104-
};
105-
const deleteRequest = filesObjectStore.delete(oldModulePath);
106-
deleteRequest.onerror = () => {
107-
console.log('IndexedDB delete request failed. deleteRequest.error is...');
108-
console.log(deleteRequest.error);
109-
throw new Error('IndexedDB delete request failed.');
110-
};
111-
}
112-
cursor.continue();
113-
} else {
114-
// The cursor is done. We have finished reading all the files.
115-
resolve();
116-
}
59+
resolve(ClientSideStorage.create(db));
11760
};
11861
});
11962
}

src/storage/module_content.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ export function makeModuleContentText(
146146

147147
export function parseModuleContentText(moduleContentText: string): ModuleContent {
148148
const parsedContent = JSON.parse(moduleContentText);
149-
fixOldParsedContent(parsedContent);
150149
if (!('moduleType' in parsedContent) ||
151150
!('moduleId' in parsedContent) ||
152151
!('blocks' in parsedContent) ||
@@ -166,38 +165,6 @@ export function parseModuleContentText(moduleContentText: string): ModuleContent
166165
parsedContent.methods);
167166
}
168167

169-
// The following function allows Alan and Liz to load older projects.
170-
// TODO(lizlooney): Remove this function.
171-
function fixOldParsedContent(parsedContent: any): void {
172-
if (!('moduleId' in parsedContent)) {
173-
parsedContent.moduleId = '';
174-
}
175-
parsedContent.mechanisms.forEach((mechanism: any) => {
176-
if (!('mechanismId' in mechanism) && ('blockId' in mechanism)) {
177-
mechanism.mechanismId = mechanism['blockId'];
178-
delete mechanism['blockId'];
179-
}
180-
});
181-
parsedContent.components.forEach((component: any) => {
182-
if (!('componentId' in component) && ('blockId' in component)) {
183-
component.componentId = component['blockId'];
184-
delete component['blockId'];
185-
}
186-
});
187-
parsedContent.events.forEach((event: any) => {
188-
if (!('eventId' in event) && ('blockId' in event)) {
189-
event.eventId = event['blockId'];
190-
delete event['blockId'];
191-
}
192-
});
193-
parsedContent.methods.forEach((method: any) => {
194-
if (!('methodId' in method) && ('blockId' in method)) {
195-
method.methodId = method['blockId'];
196-
delete method['blockId'];
197-
}
198-
});
199-
}
200-
201168
export class ModuleContent {
202169
constructor(
203170
private moduleType: storageModule.ModuleType,

0 commit comments

Comments
 (0)