From 3bc285ec7bf6ae9cd4aa84ab020cd144d0de49de Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 18 Apr 2021 19:41:19 +0200 Subject: [PATCH] Don't sync twice on startup --- src/components/ftbot/ReloadControl.vue | 14 +++++++++----- src/store/index.ts | 6 ++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/ftbot/ReloadControl.vue b/src/components/ftbot/ReloadControl.vue index 0ca73901..64197796 100644 --- a/src/components/ftbot/ReloadControl.vue +++ b/src/components/ftbot/ReloadControl.vue @@ -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(); } diff --git a/src/store/index.ts b/src/store/index.ts index 34842094..cc7736c2 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -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');