mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-21 23:53:52 +00:00
Fix small bug in handling invalid responses
This commit is contained in:
parent
3ab4aed5f4
commit
4de3a96fae
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,6 +3,8 @@ node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
|
cypress/screenshots/*
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
|
@ -216,8 +216,11 @@ export default defineComponent({
|
||||||
() => botStore.activeBotorUndefined?.openTradeCount,
|
() => botStore.activeBotorUndefined?.openTradeCount,
|
||||||
() => {
|
() => {
|
||||||
console.log('openTradeCount changed');
|
console.log('openTradeCount changed');
|
||||||
if (settingsStore.openTradesInTitle === OpenTradeVizOptions.showPill) {
|
if (
|
||||||
setOpenTradesAsPill(botStore.activeBot.openTradeCount);
|
settingsStore.openTradesInTitle === OpenTradeVizOptions.showPill &&
|
||||||
|
botStore.activeBotorUndefined?.openTradeCount
|
||||||
|
) {
|
||||||
|
setOpenTradesAsPill(botStore.activeBotorUndefined.openTradeCount);
|
||||||
} else if (settingsStore.openTradesInTitle === OpenTradeVizOptions.asTitle) {
|
} else if (settingsStore.openTradesInTitle === OpenTradeVizOptions.asTitle) {
|
||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,7 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
const res = await fetchTrades(pageLength, 0);
|
const res = await fetchTrades(pageLength, 0);
|
||||||
const result: TradeResponse = res.data;
|
const result: TradeResponse = res.data;
|
||||||
let { trades } = result;
|
let { trades } = result;
|
||||||
if (trades.length !== result.total_trades) {
|
if (Array.isArray(trades) && trades.length !== result.total_trades) {
|
||||||
// Pagination necessary
|
// Pagination necessary
|
||||||
// Don't use Promise.all - this would fire all requests at once, which can
|
// Don't use Promise.all - this would fire all requests at once, which can
|
||||||
// cause problems for big sqlite databases
|
// cause problems for big sqlite databases
|
||||||
|
@ -274,17 +274,18 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
trades = trades.concat(result.trades);
|
trades = trades.concat(result.trades);
|
||||||
totalTrades = res.data.total_trades;
|
totalTrades = res.data.total_trades;
|
||||||
} while (trades.length !== totalTrades);
|
} while (trades.length !== totalTrades);
|
||||||
|
const tradesCount = trades.length;
|
||||||
|
// Add botId to all trades
|
||||||
|
trades = trades.map((t) => ({
|
||||||
|
...t,
|
||||||
|
botId,
|
||||||
|
botName,
|
||||||
|
botTradeId: `${botId}__${t.trade_id}`,
|
||||||
|
}));
|
||||||
|
this.trades = trades;
|
||||||
|
this.tradeCount = tradesCount;
|
||||||
}
|
}
|
||||||
const tradesCount = trades.length;
|
|
||||||
// Add botId to all trades
|
|
||||||
trades = trades.map((t) => ({
|
|
||||||
...t,
|
|
||||||
botId,
|
|
||||||
botName,
|
|
||||||
botTradeId: `${botId}__${t.trade_id}`,
|
|
||||||
}));
|
|
||||||
this.trades = trades;
|
|
||||||
this.tradeCount = tradesCount;
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
|
@ -309,15 +310,17 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
// Open trades changed, so we should refresh now.
|
// Open trades changed, so we should refresh now.
|
||||||
this.refreshRequired = true;
|
this.refreshRequired = true;
|
||||||
// dispatch('refreshSlow', null, { root: true });
|
// dispatch('refreshSlow', null, { root: true });
|
||||||
}
|
|
||||||
|
|
||||||
const openTrades = result.data.map((t) => ({
|
const openTrades = result.data.map((t) => ({
|
||||||
...t,
|
...t,
|
||||||
botId,
|
botId,
|
||||||
botName,
|
botName,
|
||||||
botTradeId: `${botId}__${t.trade_id}`,
|
botTradeId: `${botId}__${t.trade_id}`,
|
||||||
}));
|
}));
|
||||||
this.openTrades = openTrades;
|
this.openTrades = openTrades;
|
||||||
|
} else {
|
||||||
|
this.openTrades = [];
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user