mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Only update selectedTradeStatistics if selected currency has
changed or we got added new trade stats
This commit is contained in:
parent
2006f58580
commit
ec7521628b
@ -132,6 +132,7 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
this.navigation = navigation;
|
||||
|
||||
setChangeListener = change -> {
|
||||
updateSelectedTradeStatistics(getCurrencyCode());
|
||||
updateChartData();
|
||||
fillTradeCurrencies();
|
||||
};
|
||||
@ -156,6 +157,7 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
fillTradeCurrenciesOnActiavetCalled = true;
|
||||
}
|
||||
buildUsdPricesPerDay();
|
||||
updateSelectedTradeStatistics(getCurrencyCode());
|
||||
updateChartData();
|
||||
syncPriceFeedCurrency();
|
||||
setMarketPriceFeedCurrency();
|
||||
@ -172,25 +174,26 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
|
||||
void onSetTradeCurrency(TradeCurrency tradeCurrency) {
|
||||
if (tradeCurrency != null) {
|
||||
final String code = tradeCurrency.getCode();
|
||||
String code = tradeCurrency.getCode();
|
||||
|
||||
if (isEditEntry(code)) {
|
||||
navigation.navigateTo(MainView.class, SettingsView.class, PreferencesView.class);
|
||||
} else {
|
||||
boolean showAllEntry = isShowAllEntry(code);
|
||||
showAllTradeCurrenciesProperty.set(showAllEntry);
|
||||
if (!showAllEntry) {
|
||||
selectedTradeCurrencyProperty.set(tradeCurrency);
|
||||
}
|
||||
preferences.setTradeChartsScreenCurrencyCode(code);
|
||||
|
||||
updateChartData();
|
||||
|
||||
if (showAllEntry)
|
||||
priceFeedService.setCurrencyCode(GlobalSettings.getDefaultTradeCurrency().getCode());
|
||||
else
|
||||
priceFeedService.setCurrencyCode(code);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean showAllEntry = isShowAllEntry(code);
|
||||
showAllTradeCurrenciesProperty.set(showAllEntry);
|
||||
if (showAllEntry) {
|
||||
priceFeedService.setCurrencyCode(GlobalSettings.getDefaultTradeCurrency().getCode());
|
||||
} else {
|
||||
selectedTradeCurrencyProperty.set(tradeCurrency);
|
||||
priceFeedService.setCurrencyCode(code);
|
||||
|
||||
}
|
||||
preferences.setTradeChartsScreenCurrencyCode(code);
|
||||
|
||||
updateSelectedTradeStatistics(getCurrencyCode());
|
||||
updateChartData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,11 +291,6 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
}
|
||||
|
||||
private void updateChartData() {
|
||||
String currencyCode = getCurrencyCode();
|
||||
selectedTradeStatistics.setAll(tradeStatisticsManager.getObservableTradeStatisticsSet().stream()
|
||||
.filter(e -> showAllTradeCurrenciesProperty.get() || e.getCurrency().equals(currencyCode))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
// Generate date range and create sets for all ticks
|
||||
itemsPerInterval = new HashMap<>();
|
||||
Date time = new Date();
|
||||
@ -345,6 +343,12 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void updateSelectedTradeStatistics(String currencyCode) {
|
||||
selectedTradeStatistics.setAll(tradeStatisticsManager.getObservableTradeStatisticsSet().stream()
|
||||
.filter(e -> showAllTradeCurrenciesProperty.get() || e.getCurrency().equals(currencyCode))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
CandleData getCandleData(long tick, Set<TradeStatistics3> set, long averageUsdPrice) {
|
||||
long open = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user