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

View File

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