Skip to content

Commit

Permalink
FIX: エンジンの再起動時にEngineInfoを更新する (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabonerune authored May 12, 2023
1 parent d4cd95a commit e811ecb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/store/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ export const engineStore = createPartialStore<EngineStoreTypes>({
},
},

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) => {
Expand Down Expand Up @@ -188,6 +208,8 @@ export const engineStore = createPartialStore<EngineStoreTypes>({
})
);

await dispatch("GET_ONLY_ENGINE_INFOS", { engineIds });

const result = await dispatch("POST_ENGINE_START", {
engineIds,
});
Expand Down
8 changes: 8 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
};

GET_SORTED_ENGINE_INFOS: {
getter: EngineInfo[];
};
Expand Down

0 comments on commit e811ecb

Please sign in to comment.