Start refresh from within store

This commit is contained in:
Matthias 2021-09-01 20:43:24 +02:00
parent d012e3166f
commit 3df41fdc68
4 changed files with 18 additions and 17 deletions

View File

@ -4,13 +4,13 @@
<RefreshIcon :size="16" /> <RefreshIcon :size="16" />
</b-button> </b-button>
<b-form-checkbox <!-- <b-form-checkbox
v-model="autoRefreshLoc" v-model="autoRefreshLoc"
class="ml-auto float-right mr-2 my-auto" class="ml-auto float-right mr-2 my-auto"
title="AutoRefresh" title="AutoRefresh"
variant="secondary" variant="secondary"
>AutoRefresh</b-form-checkbox >AutoRefresh</b-form-checkbox
> > -->
</div> </div>
</template> </template>
@ -28,18 +28,18 @@ export default class ReloadControl extends Vue {
refreshIntervalSlow: number | null = null; refreshIntervalSlow: number | null = null;
created() { created() {
if (this.loggedIn) { // if (this.loggedIn) {
this.refreshOnce(); // this.refreshOnce();
this.refreshFull(true); // this.refreshFull(true);
} // }
} }
mounted() { mounted() {
this.startRefresh(false); // this.startRefresh(false);
} }
beforeDestroy() { beforeDestroy() {
this.stopRefresh(); // this.stopRefresh();
} }
// TODO-multi: This should be per bot! // TODO-multi: This should be per bot!

View File

@ -77,4 +77,5 @@ Object.entries(UserService.getAvailableBots()).forEach(([k, v]) => {
store.dispatch('ftbot/addBot', v); store.dispatch('ftbot/addBot', v);
}); });
store.dispatch('ftbot/selectFirstBot'); store.dispatch('ftbot/selectFirstBot');
store.dispatch('ftbot/startRefresh');
export default store; export default store;

View File

@ -146,7 +146,7 @@ export default function createBotStore(store) {
console.log('dispatching all frequent refreshes'); console.log('dispatching all frequent refreshes');
getters.allAvailableBotsList.forEach((e) => { getters.allAvailableBotsList.forEach((e) => {
if (getters[`${e}/${BotStoreGetters.autoRefresh}`]) { if (getters[`${e}/${BotStoreGetters.autoRefresh}`]) {
console.log('refreshing ', e); // console.log('refreshing', e);
dispatch(`${e}/${BotStoreActions.refreshFrequent}`, slow); dispatch(`${e}/${BotStoreActions.refreshFrequent}`, slow);
} }
}); });

View File

@ -424,14 +424,14 @@ export function createBotSubStore(botId: string) {
[BotStoreActions.botAdded]({ commit }) { [BotStoreActions.botAdded]({ commit }) {
commit('setAutoRefresh', userService.getAutoRefresh()); commit('setAutoRefresh', userService.getAutoRefresh());
}, },
[BotStoreActions.ping]({ commit }) { async [BotStoreActions.ping]({ commit }) {
api try {
.get('/ping') const result = await api.get('/ping');
.then((result) => {
commit('setPing', result.data); commit('setPing', result.data);
commit('setIsBotOnline', true); commit('setIsBotOnline', true);
}) } catch (error) {
.catch(console.error); //
}
}, },
[BotStoreActions.logout]() { [BotStoreActions.logout]() {
userService.logout(); userService.logout();