Commit 00ccee1d authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[environments] fetch envs after saving the rest of the data to reduce perceived latency

parent 798343dd
......@@ -24,12 +24,11 @@ export type ActionThunkCreator = (any) => (dispatch: Dispatch<*>) => Promise<*>;
export const fetchAllObjects: ActionThunkCreator = () => async (dispatch: Dispatch<*>) => {
//console.log(`fetchAllObjects`);
const getFuncs = [...BEAT_ENTITIES, 'environments'].map(e => genModuleApiFuncs(e).get);
const getFuncs = [...BEAT_ENTITIES].map(e => genModuleApiFuncs(e).get);
const jsons = await Promise.all(getFuncs.map(async (get): Promise<*> => get()));
const arrs = jsons.map((j, i, js) => i >= js.length - 2 ? j : objToArr(j));
const arrs = jsons.map((j, i, js) => objToArr(j));
//dispatch(settingsSave(arrs[8]));
dispatch(environmentsSave(arrs[8]));
dispatch(databaseSave(arrs[0]));
dispatch(librarySave(arrs[1]));
......@@ -40,6 +39,10 @@ export const fetchAllObjects: ActionThunkCreator = () => async (dispatch: Dispat
dispatch(plotterSave(arrs[6]));
dispatch(plotterparameterSave(arrs[7]));
dispatch(clearUnsaved());
const envGet = genModuleApiFuncs('environments').get;
const envJson = await envGet();
dispatch(environmentsSave(envJson));
};
export const deleteObject = (entity: BeatEntity, obj: BeatObject): ActionThunkCreator => () => async (dispatch: Dispatch<*>) => {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment