mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 02:54:07 +00:00
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:
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user