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" />
</b-button>
<b-form-checkbox
<!-- <b-form-checkbox
v-model="autoRefreshLoc"
class="ml-auto float-right mr-2 my-auto"
title="AutoRefresh"
variant="secondary"
>AutoRefresh</b-form-checkbox
>
> -->
</div>
</template>
@ -28,18 +28,18 @@ export default class ReloadControl extends Vue {
refreshIntervalSlow: number | null = null;
created() {
if (this.loggedIn) {
this.refreshOnce();
this.refreshFull(true);
}
// if (this.loggedIn) {
// this.refreshOnce();
// this.refreshFull(true);
// }
}
mounted() {
this.startRefresh(false);
// this.startRefresh(false);
}
beforeDestroy() {
this.stopRefresh();
// this.stopRefresh();
}
// 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/selectFirstBot');
store.dispatch('ftbot/startRefresh');
export default store;

View File

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

View File

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