Use getter for current locks

This commit is contained in:
Matthias 2020-10-25 11:36:22 +01:00
parent 8ec31cbb35
commit 833526fee2
2 changed files with 11 additions and 5 deletions

View File

@ -5,14 +5,15 @@
<b-button class="float-right" size="sm" @click="getLocks">&#x21bb;</b-button>
</div>
<div>
<b-table class="table-sm" :items="locks.locks" :fields="tableFields"> </b-table>
<b-table class="table-sm" :items="currentLocks" :fields="tableFields"> </b-table>
</div>
</div>
</template>
<script lang="ts">
import { timestampms } from '@/shared/formatters';
import { LockResponse } from '@/types';
import { BotStoreGetters } from '@/store/modules/ftbot';
import { Lock } from '@/types';
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
@ -22,7 +23,7 @@ const ftbot = namespace('ftbot');
export default class PairLockList extends Vue {
@ftbot.Action getLocks;
@ftbot.State locks!: LockResponse;
@ftbot.Getter [BotStoreGetters.currentLocks]!: Lock;
timestampms = timestampms;

View File

@ -18,6 +18,7 @@ import {
BalanceInterface,
DailyReturnValue,
LockResponse,
Lock,
} from '@/types';
import {
@ -33,6 +34,7 @@ export enum BotStoreGetters {
tradeDetail = 'tradeDetail',
closedTrades = 'closedTrades',
allTrades = 'allTrades',
currentLocks = 'currentLocks',
plotConfig = 'plotConfig',
plotConfigNames = 'plotConfigNames',
timeframe = 'timeframe',
@ -64,7 +66,7 @@ export default {
strategyList: [],
strategy: {},
pairlist: [],
locks: [],
currentLocks: [],
},
getters: {
[BotStoreGetters.plotConfig](state) {
@ -79,6 +81,9 @@ export default {
[BotStoreGetters.allTrades](state): Trade[] {
return [...state.openTrades, ...state.trades];
},
[BotStoreGetters.currentLocks](state): Lock[] {
return state.currentLocks.locks;
},
[BotStoreGetters.tradeDetail](state): Trade {
let dTrade = state.openTrades.find((item) => item.trade_id === state.detailTradeId);
if (!dTrade) {
@ -102,7 +107,7 @@ export default {
state.openTrades = trades;
},
updateLocks(state, locks: LockResponse) {
state.locks = locks;
state.currentLocks = locks;
},
updatePerformance(state, performance) {
state.performanceStats = performance;