mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 21:15:15 +00:00
Improve sync behaviour
This commit is contained in:
parent
b477a9dddd
commit
43676179dc
|
@ -28,7 +28,7 @@ export function useApi(userService: UserService, botId: string) {
|
||||||
(err) => {
|
(err) => {
|
||||||
// console.log(err);
|
// console.log(err);
|
||||||
if (err.response && err.response.status === 401) {
|
if (err.response && err.response.status === 401) {
|
||||||
console.log('Dispatching refresh_token...');
|
console.log('Fetching refresh_token...');
|
||||||
return userService
|
return userService
|
||||||
.refreshToken()
|
.refreshToken()
|
||||||
.then((token) => {
|
.then((token) => {
|
||||||
|
|
|
@ -184,17 +184,13 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
rename(name: string) {
|
rename(name: string) {
|
||||||
userService.renameBot(name);
|
userService.renameBot(name);
|
||||||
},
|
},
|
||||||
setRefreshRequired(refreshRequired: boolean) {
|
|
||||||
this.refreshRequired = refreshRequired;
|
|
||||||
},
|
|
||||||
setAutoRefresh(newRefreshValue) {
|
setAutoRefresh(newRefreshValue) {
|
||||||
this.autoRefresh = newRefreshValue;
|
this.autoRefresh = newRefreshValue;
|
||||||
// TODO: Investigate this -
|
// TODO: Investigate this -
|
||||||
// this ONLY works if ReloadControl is only visible once,otherwise it triggers twice
|
// this ONLY works if ReloadControl is only visible once,otherwise it triggers twice
|
||||||
if (newRefreshValue) {
|
if (newRefreshValue) {
|
||||||
// dispatch('startRefresh', true);
|
this.refreshFrequent();
|
||||||
} else {
|
this.refreshSlow(true);
|
||||||
// dispatch('stopRefresh');
|
|
||||||
}
|
}
|
||||||
userService.setAutoRefresh(newRefreshValue);
|
userService.setAutoRefresh(newRefreshValue);
|
||||||
},
|
},
|
||||||
|
@ -274,17 +270,17 @@ 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) {
|
||||||
|
@ -309,18 +305,16 @@ 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 });
|
this.refreshSlow(false);
|
||||||
|
|
||||||
const openTrades = result.data.map((t) => ({
|
|
||||||
...t,
|
|
||||||
botId,
|
|
||||||
botName,
|
|
||||||
botTradeId: `${botId}__${t.trade_id}`,
|
|
||||||
}));
|
|
||||||
this.openTrades = openTrades;
|
|
||||||
} else {
|
|
||||||
this.openTrades = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openTrades = result.data.map((t) => ({
|
||||||
|
...t,
|
||||||
|
botId,
|
||||||
|
botName,
|
||||||
|
botTradeId: `${botId}__${t.trade_id}`,
|
||||||
|
}));
|
||||||
|
this.openTrades = openTrades;
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
},
|
},
|
||||||
|
|
|
@ -172,7 +172,6 @@ export const useBotStore = defineStore('wrapper', {
|
||||||
delete this.availableBots[botId];
|
delete this.availableBots[botId];
|
||||||
this.botStores = { ...this.botStores };
|
this.botStores = { ...this.botStores };
|
||||||
this.availableBots = { ...this.availableBots };
|
this.availableBots = { ...this.availableBots };
|
||||||
// commit('removeBot', botId);
|
|
||||||
} else {
|
} else {
|
||||||
console.warn(`bot ${botId} not found! could not remove`);
|
console.warn(`bot ${botId} not found! could not remove`);
|
||||||
}
|
}
|
||||||
|
@ -314,4 +313,5 @@ export function initBots() {
|
||||||
botStore.addBot(v);
|
botStore.addBot(v);
|
||||||
});
|
});
|
||||||
botStore.selectFirstBot();
|
botStore.selectFirstBot();
|
||||||
|
botStore.startRefresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@ export const useSettingsStore = defineStore('uiSettings', {
|
||||||
const result = await axios.get<UiVersion>('/ui_version');
|
const result = await axios.get<UiVersion>('/ui_version');
|
||||||
const { version } = result.data;
|
const { version } = result.data;
|
||||||
this.uiVersion = version;
|
this.uiVersion = version;
|
||||||
// commit('setUIVersion', version);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user