mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 04:55:15 +00:00
Store autorefresh state
This commit is contained in:
parent
2bd0198697
commit
afeec39cd5
|
@ -4,7 +4,7 @@
|
||||||
Refresh all
|
Refresh all
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<b-form-checkbox class="float-right" v-model="autoRefresh" size="lg" switch
|
<b-form-checkbox class="float-right" v-model="autoRefreshLoc" size="lg" switch
|
||||||
>AutoRefresh</b-form-checkbox
|
>AutoRefresh</b-form-checkbox
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,8 +16,6 @@ import { Action, State } from 'vuex-class';
|
||||||
|
|
||||||
@Component({})
|
@Component({})
|
||||||
export default class ReloadControl extends Vue {
|
export default class ReloadControl extends Vue {
|
||||||
autoRefresh = true;
|
|
||||||
|
|
||||||
refreshInterval: NodeJS.Timer | null = null;
|
refreshInterval: NodeJS.Timer | null = null;
|
||||||
|
|
||||||
refreshIntervalSlow: NodeJS.Timer | null = null;
|
refreshIntervalSlow: NodeJS.Timer | null = null;
|
||||||
|
@ -39,6 +37,10 @@ export default class ReloadControl extends Vue {
|
||||||
|
|
||||||
@State loggedIn;
|
@State loggedIn;
|
||||||
|
|
||||||
|
@State autoRefresh!: boolean;
|
||||||
|
|
||||||
|
@Action setAutoRefresh!: (newValue: boolean) => void;
|
||||||
|
|
||||||
@Action refreshSlow;
|
@Action refreshSlow;
|
||||||
|
|
||||||
@Action refreshFrequent;
|
@Action refreshFrequent;
|
||||||
|
@ -47,6 +49,14 @@ export default class ReloadControl extends Vue {
|
||||||
|
|
||||||
@Action refreshOnce;
|
@Action refreshOnce;
|
||||||
|
|
||||||
|
get autoRefreshLoc() {
|
||||||
|
return this.autoRefresh;
|
||||||
|
}
|
||||||
|
|
||||||
|
set autoRefreshLoc(newValue: boolean) {
|
||||||
|
this.setAutoRefresh(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
startRefresh() {
|
startRefresh() {
|
||||||
if (this.loggedIn !== true) {
|
if (this.loggedIn !== true) {
|
||||||
console.log('Not logged in.');
|
console.log('Not logged in.');
|
||||||
|
|
|
@ -5,12 +5,15 @@ import userService from '@/shared/userService';
|
||||||
import ftbotModule from './modules/ftbot';
|
import ftbotModule from './modules/ftbot';
|
||||||
import alertsModule from './modules/alerts';
|
import alertsModule from './modules/alerts';
|
||||||
|
|
||||||
|
const AUTO_REFRESH = 'ft_auto_refresh';
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
ping: '',
|
ping: '',
|
||||||
loggedIn: userService.loggedIn(),
|
loggedIn: userService.loggedIn(),
|
||||||
|
autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || 'false'),
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {
|
||||||
ftbot: ftbotModule,
|
ftbot: ftbotModule,
|
||||||
|
@ -25,8 +28,15 @@ export default new Vuex.Store({
|
||||||
setLoggedIn(state, loggedin: boolean) {
|
setLoggedIn(state, loggedin: boolean) {
|
||||||
state.loggedIn = loggedin;
|
state.loggedIn = loggedin;
|
||||||
},
|
},
|
||||||
|
setAutoRefresh(state, newRefreshValue: boolean) {
|
||||||
|
state.autoRefresh = newRefreshValue;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
setAutoRefresh({ commit }, newRefreshValue) {
|
||||||
|
commit('setAutoRefresh', newRefreshValue);
|
||||||
|
localStorage.setItem(AUTO_REFRESH, JSON.stringify(newRefreshValue));
|
||||||
|
},
|
||||||
refreshOnce({ dispatch }) {
|
refreshOnce({ dispatch }) {
|
||||||
dispatch('ftbot/getVersion');
|
dispatch('ftbot/getVersion');
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user