Skip to content

Commit

Permalink
Add info if burningman accounting data processing is disabled or if i…
Browse files Browse the repository at this point in the history
…t 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 <[email protected]>
  • Loading branch information
HenrikJannsen committed Apr 10, 2023
1 parent 25fa962 commit 795964f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
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;
Expand Down Expand Up @@ -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,
Expand All @@ -105,6 +110,7 @@ public void addListeners() {

@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));

Expand All @@ -125,6 +131,7 @@ public void start() {
public void onInitialBlockRequestsComplete() {
updateBalanceModelByAddress();
burningManAccountingStoreService.forEachBlock(this::addAccountingBlockToBalanceModel);
UserThread.execute(() -> isProcessing.set(false));
}

public void onNewBlockReceived(AccountingBlock accountingBlock) {
Expand All @@ -133,7 +140,7 @@ public void onNewBlockReceived(AccountingBlock accountingBlock) {
}

public void addBlock(AccountingBlock block) throws BlockHashNotConnectingException, BlockHeightNotConnectingException {
burningManAccountingStoreService.addIfNewBlock(block);
burningManAccountingStoreService.addIfNewBlock(block);
}

public int getBlockHeightOfLastBlock() {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -243,6 +243,7 @@ private BurningManView(DaoFacade daoFacade,
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"))
Expand Down Expand Up @@ -280,6 +281,16 @@ private BurningManView(DaoFacade daoFacade,
}
};
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"));
}
}
};
}


Expand Down Expand Up @@ -576,6 +587,8 @@ protected void activate() {

balanceEntryToggleGroup.selectedToggleProperty().addListener(balanceEntryToggleListener);

burningManAccountingService.getIsProcessing().addListener(isProcessingListener);

burningManSortedList.comparatorProperty().bind(burningManTableView.comparatorProperty());
burnOutputsSortedList.comparatorProperty().bind(burnOutputsTableView.comparatorProperty());
balanceEntrySortedList.comparatorProperty().bind(balanceEntryTableView.comparatorProperty());
Expand Down Expand Up @@ -615,6 +628,8 @@ protected void deactivate() {

balanceEntryToggleGroup.selectedToggleProperty().removeListener(balanceEntryToggleListener);

burningManAccountingService.getIsProcessing().removeListener(isProcessingListener);

burningManSortedList.comparatorProperty().unbind();
burnOutputsSortedList.comparatorProperty().unbind();
balanceEntrySortedList.comparatorProperty().unbind();
Expand Down

0 comments on commit 795964f

Please sign in to comment.