Fix loading of refresh setting

This commit is contained in:
Matthias 2021-09-01 20:07:38 +02:00
parent be4b90f5a3
commit 0467a18649
2 changed files with 6 additions and 2 deletions

View File

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

View File

@ -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')