diff --git a/src/store/engine.ts b/src/store/engine.ts index f8cca51a22..803b8c9e6e 100644 --- a/src/store/engine.ts +++ b/src/store/engine.ts @@ -31,6 +31,26 @@ export const engineStore = createPartialStore({ }, }, + SET_ENGINE_INFO: { + mutation(state, { engineId, engineInfo }) { + state.engineInfos[engineId] = engineInfo; + }, + }, + + GET_ONLY_ENGINE_INFOS: { + async action({ commit }, { engineIds }) { + const engineInfos = await window.electron.engineInfos(); + for (const engineInfo of engineInfos) { + if (engineIds.includes(engineInfo.uuid)) { + commit("SET_ENGINE_INFO", { + engineId: engineInfo.uuid, + engineInfo, + }); + } + } + }, + }, + GET_SORTED_ENGINE_INFOS: { getter: (state) => { return Object.values(state.engineInfos).sort((a, b) => { @@ -188,6 +208,8 @@ export const engineStore = createPartialStore({ }) ); + await dispatch("GET_ONLY_ENGINE_INFOS", { engineIds }); + const result = await dispatch("POST_ENGINE_START", { engineIds, }); diff --git a/src/store/type.ts b/src/store/type.ts index 1c5ab4c99c..feba5eb2c2 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -735,6 +735,14 @@ export type EngineStoreTypes = { action(): void; }; + SET_ENGINE_INFO: { + mutation: { engineId: EngineId; engineInfo: EngineInfo }; + }; + + GET_ONLY_ENGINE_INFOS: { + action: (payload: { engineIds: EngineId[] }) => Promise; + }; + GET_SORTED_ENGINE_INFOS: { getter: EngineInfo[]; };