pinia: some small adjustments

This commit is contained in:
Matthias 2022-04-18 13:13:45 +02:00
parent 673cc4e4c0
commit aed1e7da73
2 changed files with 5 additions and 1 deletions

View File

@ -110,6 +110,7 @@ export function createBotSubStore(botId: string, botName: string) {
isWebserverMode: (state) => state.botState?.runmode === RunModes.WEBSERVER,
selectedBacktestResult: (state) => state.backtestHistory[state.selectedBacktestResultKey],
shortAllowed: (state) => state.botState?.short_allowed || false,
openTradeCount: (state) => state.openTrades.length,
isTrading: (state) =>
state.botState?.runmode === RunModes.LIVE || state.botState?.runmode === RunModes.DRY_RUN,
timeframe: (state) => state.botState?.timeframe || '',
@ -789,6 +790,5 @@ export function createBotSubStore(botId: string, botName: string) {
},
},
});
return useBotStore();
}

View File

@ -23,7 +23,11 @@ export const useBotStore = defineStore('wrapper', {
},
getters: {
hasBots: (state) => Object.keys(state.availableBots).length > 0,
botCount: (state) => Object.keys(state.availableBots).length,
allBotStores: (state) => Object.values(state.botStores),
activeBot: (state) =>
state.botStores[state.selectedBot] as ReturnType<typeof createBotSubStore>,
selectedBotObj: (state) => state.availableBots[state.selectedBot],
},
actions: {
selectBot(botId: string) {