beancount / fava

Fava - web interface for Beancount
https://beancount.github.io/fava/
MIT License
1.95k stars 286 forks source link

Regression in functionality due to storing displayed transaction types in localStorage #1458

Open aronsky opened 2 years ago

aronsky commented 2 years ago

I understand the rationale behind the change in the latest version of Fava, that stores the transaction types displayed in the Journal view in localStorage.

However, for certain use-cases, it's a regression in functionality, and I'm wondering whether a workaround is possible. Specifically, in my case, I have a custom link in the left toolbar called Pending, which takes me to a view of the journal with pending transactions only. My importers mark all new transactions pending (!), and every few days, I open Fava, go to my Pending view, and clear those transactions (! -> *). This flow regressed working since the last version, as Fava ignores the show parameter. So, if I viewed the journal with cleared transactions beforehand, they are now shown to me in the Pending view. And conversely, if I manually select to view only pending transactions in the Pending view, next time I go to the journal view, only pending transactions are shown.

Is it possible to make the show parameter override whatever is stored in localStorage? I know it's problematic, because then, if the user changes the displayed transaction types, what state should be modified? I'm open to suggestions.

wylfen commented 2 years ago

I have a similiar workflow but in reverse, I sometimes want to hide all pending transactions - I use them as a marker for whether or not the transaction has cleared with the payment provider/bank.

Instead of using show, I use a custom link with the special /jump handler that sets the filter attribute:

2020-03-03 custom "fava-sidebar-link" "Ignore pending" "/jump?filter=-flag%3A+\"!\""

Clicking this link activates the filter on the current page. Perhaps a workaround for you would be the following setting, which jumps to the journal whilst passing along a filter that shows only pending transactions:

2022-07-27 custom "fava-sidebar-link" "Only pending" "../journal?filter=flag%3A+\"!'\""

I don't think the flag filter is documented anywhere, I honestly forgot where I found it. It's quite likely I had a look in the code.

aronsky commented 2 years ago

Thank you for the suggestion! It does work, but the filter expression remains when I navigate away from the page (which is usually not what I'd want, especially since it filters away most of the transactions in the ledger).

wylfen commented 2 years ago

Yeah, that is something that remains to be fixed with my approach. Sadly I don't think there's a way right now to clear filters automatically by navigating away from a page. I've been resetting it manually...

comigor commented 1 year ago

+1 on this, I've been using an old version that still leverages query parameters instead of localStorage because of this.

yagebu commented 1 year ago

Is it possible to make the show parameter override whatever is stored in localStorage?

I think having some specific query parameter, maybe ?set-journal-show=["..."] or ?set=journal-show&value=["..."] to set the localStorage values (on page load) would make sense to have. Combined with the /jump endpoint that should provide a good solution for the given problem. A PR implementing this would be welcome :)