Fix setIsBotOnline

This commit is contained in:
Matthias 2021-08-31 20:30:19 +02:00
parent b73c5cbaed
commit 10d13d788e
3 changed files with 7 additions and 10 deletions

View File

@ -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) => {

View File

@ -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 {

View File

@ -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');
},