diff --git a/src/store/modules/botStoreWrapper.ts b/src/store/modules/botStoreWrapper.ts index 97b81a1e..dabb5747 100644 --- a/src/store/modules/botStoreWrapper.ts +++ b/src/store/modules/botStoreWrapper.ts @@ -111,7 +111,7 @@ export default function createBotStore(store) { const actions = { // Actions automatically filled below - addBot({ getters, commit }, bot: BotDescriptor) { + addBot({ dispatch, getters, commit }, bot: BotDescriptor) { if (Object.keys(getters.allAvailableBots).includes(bot.botId)) { // throw 'Bot already present'; // TODO: handle error! @@ -120,6 +120,7 @@ export default function createBotStore(store) { } console.log('add bot', bot); store.registerModule(['ftbot', bot.botId], createBotSubStore(bot.botId)); + dispatch(`${bot.botId}/botAdded`); commit('addBot', bot); }, removeBot({ commit, getters, dispatch }, botId: string) { diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts index 2b091091..404a217a 100644 --- a/src/store/modules/ftbot/index.ts +++ b/src/store/modules/ftbot/index.ts @@ -93,6 +93,7 @@ export enum BotStoreGetters { } export enum BotStoreActions { + botAdded = 'botAdded', ping = 'ping', setIsBotOnline = 'setIsBotOnline', setAutoRefresh = 'setAutoRefresh', @@ -142,7 +143,6 @@ export function createBotSubStore(botId: string) { const userService = useUserService(botId); const { api } = useApi(userService, botId); - return { namespaced: true, state, @@ -421,6 +421,9 @@ export function createBotSubStore(botId: string) { }, }, actions: { + [BotStoreActions.botAdded]({ commit }) { + commit('setAutoRefresh', userService.getAutoRefresh()); + }, [BotStoreActions.ping]({ commit }) { api .get('/ping')