Skip to content

Commit

Permalink
Setup initial filter when opening all transactions view
Browse files Browse the repository at this point in the history
Issue: #3491
Signed-off-by: OnkelDok <90478568+OnkelDok@users.noreply.github.com>
[removed wrong comment; rebased to master]
Signed-off-by: Andreas Buchen <andreas.buchen@gmail.com>
  • Loading branch information
OnkelDok authored and buchen committed Aug 9, 2023
1 parent 12d5505 commit 91d389b
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,31 @@ public FilterDropDown(IPreferenceStore preferenceStore)

Consumer<ClientFilter> listener = f -> {
setInformationPaneInput(null);
if (f instanceof PortfolioClientFilter pcf)
AllTransactionsView.this.clientFilter = pcf;
else
AllTransactionsView.this.clientFilter = null;
setupFilterInView(f);
notifyModelUpdated();
};

clientFilterMenu.addListener(listener);
clientFilterMenu.addListener(f -> updateIcon());

// as we register the listener above, the selected filter will be
// injected into the view immediately
clientFilterMenu.trackSelectedFilterConfigurationKey(AllTransactionsView.class.getSimpleName());

// set initial filter
setupFilterInView(clientFilterMenu.getSelectedFilter());

updateIcon();

addDisposeListener(e -> preferenceStore.setValue(TRANSACTION_FILTER_PREFERENCE_NAME, typeFilter.name()));
}

private void setupFilterInView(ClientFilter filter)
{
if (filter instanceof PortfolioClientFilter pcf)
AllTransactionsView.this.clientFilter = pcf;
else
AllTransactionsView.this.clientFilter = null;
}

private void updateIcon()
{
boolean hasActiveFilter = clientFilterMenu.hasActiveFilter() || typeFilter != DEFAULT_TYPE_FILTER;
Expand Down

0 comments on commit 91d389b

Please sign in to comment.