Add info if burningman accounting data processing is disabled or if it is in progress.

We use a postfix to the header title and not a busy animation, as the busy animation is quite CPU intense.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2023-04-10 16:01:13 +07:00
parent 25fa962e5e
commit 795964f06b
No known key found for this signature in database
GPG key ID: 02AA2BAE387C8307
3 changed files with 26 additions and 2 deletions

View file

@ -43,6 +43,9 @@ import org.bitcoinj.core.Coin;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@ -82,6 +85,8 @@ public class BurningManAccountingService implements DaoSetupService {
private final Map<Date, Price> averageBsqPriceByMonth = new HashMap<>(getHistoricalAverageBsqPriceByMonth());
@Getter
private final Map<String, BalanceModel> balanceModelByBurningManName = new HashMap<>();
@Getter
private BooleanProperty isProcessing = new SimpleBooleanProperty();
@Inject
public BurningManAccountingService(BurningManAccountingStoreService burningManAccountingStoreService,
@ -105,6 +110,7 @@ public class BurningManAccountingService implements DaoSetupService {
@Override
public void start() {
UserThread.execute(() -> isProcessing.set(true));
// Create the map from now back to the last entry of the historical data (April 2019-Nov. 2022).
averageBsqPriceByMonth.putAll(getAverageBsqPriceByMonth(new Date(), 2022, 10));
@ -125,6 +131,7 @@ public class BurningManAccountingService implements DaoSetupService {
public void onInitialBlockRequestsComplete() {
updateBalanceModelByAddress();
burningManAccountingStoreService.forEachBlock(this::addAccountingBlockToBalanceModel);
UserThread.execute(() -> isProcessing.set(false));
}
public void onNewBlockReceived(AccountingBlock accountingBlock) {
@ -133,7 +140,7 @@ public class BurningManAccountingService implements DaoSetupService {
}
public void addBlock(AccountingBlock block) throws BlockHashNotConnectingException, BlockHeightNotConnectingException {
burningManAccountingStoreService.addIfNewBlock(block);
burningManAccountingStoreService.addIfNewBlock(block);
}
public int getBlockHeightOfLastBlock() {

View file

@ -2324,6 +2324,8 @@ dao.burningman.daoBalance=Balance for DAO
dao.burningman.daoBalanceTotalBurned=Total amount of burned BSQ
dao.burningman.daoBalanceTotalDistributed=Total amount of distributed BTC / BSQ
dao.burningman.selectedContributor=Selected contributor
dao.burningman.selectedContributor.disabledAccounting=(accounting data not updated)
dao.burningman.selectedContributor.processing=(still processing data...)
dao.burningman.selectedContributorName=Contributor name
dao.burningman.selectedContributorTotalReceived=Total received
dao.burningman.selectedContributorTotalRevenue=Total revenue

View file

@ -154,7 +154,6 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
private TableView<CompensationListItem> compensationsTableView;
private TableView<ReimbursementListItem> reimbursementsTableView;
private final ObservableList<BurningManListItem> burningManObservableList = FXCollections.observableArrayList();
private final FilteredList<BurningManListItem> burningManFilteredList = new FilteredList<>(burningManObservableList);
private final SortedList<BurningManListItem> burningManSortedList = new SortedList<>(burningManFilteredList);
@ -174,6 +173,7 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
private final ChangeListener<String> filterListener;
private final ChangeListener<BurningManListItem> contributorsListener;
private final ChangeListener<Toggle> balanceEntryToggleListener;
private final ChangeListener<Boolean> isProcessingListener;
private int gridRow = 0;
private boolean showMonthlyBalanceEntries = true;
@ -243,6 +243,7 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
if (preferences.isProcessBurningManAccountingData()) {
onBurningManSelected(newValue);
} else {
selectedContributorTitledGroupBg.setText(Res.get("dao.burningman.selectedContributor") + " " + Res.get("dao.burningman.selectedContributor.disabledAccounting"));
String key = "processBurningManAccountingData";
if (preferences.showAgain(key)) {
new Popup().information(Res.get("dao.burningman.accounting.popup"))
@ -280,6 +281,16 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
}
};
balanceEntryToggleListener = (observable, oldValue, newValue) -> onTypeChanged();
isProcessingListener = (observable, oldValue, newValue) -> {
if (preferences.isProcessBurningManAccountingData()) {
if (newValue) {
selectedContributorTitledGroupBg.setText(Res.get("dao.burningman.selectedContributor") + " " + Res.get("dao.burningman.selectedContributor.processing"));
} else {
selectedContributorTitledGroupBg.setText(Res.get("dao.burningman.selectedContributor"));
}
}
};
}
@ -576,6 +587,8 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
balanceEntryToggleGroup.selectedToggleProperty().addListener(balanceEntryToggleListener);
burningManAccountingService.getIsProcessing().addListener(isProcessingListener);
burningManSortedList.comparatorProperty().bind(burningManTableView.comparatorProperty());
burnOutputsSortedList.comparatorProperty().bind(burnOutputsTableView.comparatorProperty());
balanceEntrySortedList.comparatorProperty().bind(balanceEntryTableView.comparatorProperty());
@ -615,6 +628,8 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
balanceEntryToggleGroup.selectedToggleProperty().removeListener(balanceEntryToggleListener);
burningManAccountingService.getIsProcessing().removeListener(isProcessingListener);
burningManSortedList.comparatorProperty().unbind();
burnOutputsSortedList.comparatorProperty().unbind();
balanceEntrySortedList.comparatorProperty().unbind();