Don't sync twice on startup

This commit is contained in:
Matthias 2021-04-18 19:41:19 +02:00
parent 2af9aeb28a
commit 3bc285ec7b
2 changed files with 13 additions and 7 deletions

View File

@ -33,7 +33,7 @@ export default class ReloadControl extends Vue {
}
mounted() {
this.startRefresh();
this.startRefresh(false);
}
beforeDestroy() {
@ -63,19 +63,23 @@ export default class ReloadControl extends Vue {
this.setAutoRefresh(newValue);
}
startRefresh() {
startRefresh(runNow: boolean) {
if (this.loggedIn !== true) {
console.log('Not logged in.');
return;
}
console.log('Starting automatic refresh.');
this.refreshFrequent();
if (runNow) {
this.refreshFrequent(false);
}
if (this.autoRefresh) {
this.refreshInterval = window.setInterval(() => {
this.refreshFrequent();
}, 5000);
}
this.refreshSlow(true);
if (runNow) {
this.refreshSlow(true);
}
if (this.autoRefresh) {
this.refreshIntervalSlow = window.setInterval(() => {
this.refreshSlow(false);
@ -96,7 +100,7 @@ export default class ReloadControl extends Vue {
@Watch('autoRefresh')
watchAutoRefresh(val) {
if (val) {
this.startRefresh();
this.startRefresh(true);
} else {
this.stopRefresh();
}

View File

@ -117,8 +117,10 @@ export default new Vuex.Store({
commit('ftbot/updateRefreshRequired', false);
}
},
refreshFrequent({ dispatch }) {
dispatch('refreshSlow', false);
refreshFrequent({ dispatch }, slow = true) {
if (slow) {
dispatch('refreshSlow', false);
}
// Refresh data that's needed in near realtime
dispatch('ftbot/getOpenTrades');
dispatch('ftbot/getState');