Prevent using botbalance when it doesn't work

This commit is contained in:
Matthias 2023-04-22 17:31:54 +02:00
parent 1d4121f38b
commit f5c9fa0f79

View File

@ -4,7 +4,7 @@
<label class="me-auto h3">Balance</label> <label class="me-auto h3">Balance</label>
<div class="float-end d-flex flex-row"> <div class="float-end d-flex flex-row">
<b-button <b-button
v-if="botStore.activeBot.botApiVersion >= 2.26" v-if="canUseBotBalance"
size="sm" size="sm"
:title="!showBotOnly ? 'Showing Account balance' : 'Showing Bot balance'" :title="!showBotOnly ? 'Showing Account balance' : 'Showing Bot balance'"
@click="showBotOnly = !showBotOnly" @click="showBotOnly = !showBotOnly"
@ -46,7 +46,7 @@
<!-- this is a computed prop that adds up all the expenses in the visible rows --> <!-- this is a computed prop that adds up all the expenses in the visible rows -->
<td> <td>
<strong>{{ <strong>{{
showBotOnly showBotOnly && canUseBotBalance
? formatCurrency(botStore.activeBot.balance.total_bot) ? formatCurrency(botStore.activeBot.balance.total_bot)
: formatCurrency(botStore.activeBot.balance.total) : formatCurrency(botStore.activeBot.balance.total)
}}</strong> }}</strong>
@ -76,13 +76,15 @@ const smallBalance = computed<number>(() => {
return Number((1.1 ** botStore.activeBot.stakeCurrencyDecimals).toFixed(8)); return Number((1.1 ** botStore.activeBot.stakeCurrencyDecimals).toFixed(8));
}); });
const canUseBotBalance = computed(() => {
return botStore.activeBot.botApiVersion >= 2.26;
});
const balanceCurrencies = computed(() => { const balanceCurrencies = computed(() => {
return botStore.activeBot.balance.currencies?.filter( return botStore.activeBot.balance.currencies?.filter(
(v) => (v) =>
(!hideSmallBalances.value || v.est_stake >= smallBalance.value) && (!hideSmallBalances.value || v.est_stake >= smallBalance.value) &&
(botStore.activeBot.botApiVersion < 2.26 || (!canUseBotBalance.value || !showBotOnly.value || (v.is_bot_managed ?? true) === true),
!showBotOnly.value ||
(v.is_bot_managed ?? true) === true),
); );
}); });
@ -94,12 +96,12 @@ const tableFields = computed<TableField[]>(() => {
return [ return [
{ key: 'currency', label: 'Currency' }, { key: 'currency', label: 'Currency' },
{ {
key: showBotOnly.value ? 'bot_owned' : 'free', key: showBotOnly.value && canUseBotBalance.value ? 'bot_owned' : 'free',
label: 'Available', label: 'Available',
formatter: formatCurrency, formatter: formatCurrency,
}, },
{ {
key: showBotOnly.value ? 'est_stake_bot' : 'est_stake', key: showBotOnly.value && canUseBotBalance.value ? 'est_stake_bot' : 'est_stake',
label: `in ${botStore.activeBot.balance.stake}`, label: `in ${botStore.activeBot.balance.stake}`,
formatter: formatCurrency, formatter: formatCurrency,
}, },