fileStorage/sagas: remove editor init from fileStorage

This is still a bit of a hack but is one step towards being able to
remove the 'editor' context.
This commit is contained in:
David Lechner
2022-03-26 11:49:23 -05:00
parent 0715ce3de1
commit 3eac7d384f
3 changed files with 61 additions and 16 deletions
+1 -16
View File
@@ -6,9 +6,8 @@ import JSZip from 'jszip';
import localForage from 'localforage';
import { extendPrototype } from 'localforage-observable';
import { eventChannel } from 'redux-saga';
import { call, fork, getContext, put, takeEvery } from 'typed-redux-saga/macro';
import { call, fork, put, takeEvery } from 'typed-redux-saga/macro';
import Observable from 'zen-observable';
import { EditorType } from '../editor/Editor';
import { pythonFileExtension, pythonFileMimeType } from '../pybricksMicropython/lib';
import { ensureError, timestamp } from '../utils';
import {
@@ -269,20 +268,6 @@ function* initialize(): Generator {
const fileNames = yield* call(() => files.keys());
// TODO: we should not be loading main.py here
// HACK: This assumes that editor is loaded before storage!
const editor = yield* getContext<EditorType>('editor');
if (editor) {
const main = yield* call(() => files.getItem<string>('main.py'));
if (main) {
editor.setValue(main);
}
} else if (process.env.NODE_ENV !== 'test') {
console.error('editor was not loaded, so main.py was not loaded');
}
yield* put(fileStorageDidInitialize(fileNames));
} catch (err) {
yield* put(fileStorageDidFailToInitialize(ensureError(err)));