diff --git a/src/shared/apiService.ts b/src/shared/apiService.ts index 241e6f5a..6a0797de 100644 --- a/src/shared/apiService.ts +++ b/src/shared/apiService.ts @@ -6,7 +6,7 @@ import { UserService } from './userService'; */ let globalStore; -export function useApi(userService: UserService) { +export function useApi(userService: UserService, botId: string) { const api = axios.create({ baseURL: userService.getBaseUrl(), timeout: 10000, @@ -60,7 +60,7 @@ export function useApi(userService: UserService) { } if ((err.response && err.response.status === 500) || err.message === 'Network Error') { console.log('Bot not running...'); - globalStore.dispatch('setIsBotOnline', false); + globalStore.dispatch(`ftbot/${botId}/setIsBotOnline`, false); } return new Promise((resolve, reject) => { diff --git a/src/store/index.ts b/src/store/index.ts index 922eb2eb..e3bb27ff 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -57,13 +57,6 @@ const store = new Vuex.Store({ setLoggedIn({ commit }, loggedin: boolean) { commit('setLoggedIn', loggedin); }, - setIsBotOnline({ commit, dispatch }, isOnline) { - commit('setIsBotOnline', isOnline); - if (isOnline === false) { - console.log('disabling autorun'); - dispatch('ftbot/setAutoRefresh', false); - } - }, async loadUIVersion({ commit }) { if (process.env.NODE_ENV !== 'development') { try { diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts index b0d5c59a..2b8efe66 100644 --- a/src/store/modules/ftbot/index.ts +++ b/src/store/modules/ftbot/index.ts @@ -133,7 +133,8 @@ export enum BotStoreActions { export function createBotSubStore(botId: string) { const userService = useUserService(botId); - const { api } = useApi(userService); + const { api } = useApi(userService, botId); + return { namespaced: true, @@ -410,6 +411,9 @@ export function createBotSubStore(botId: string) { [BotStoreActions.setRefreshRequired]({ commit }, refreshRequired: boolean) { commit('updateRefreshRequired', refreshRequired); }, + [BotStoreActions.setIsBotOnline]({ commit }, refreshRequired: boolean) { + commit('setIsBotOnline', refreshRequired); + }, [BotStoreActions.refreshOnce]({ dispatch }) { dispatch('getVersion'); },