In RCFilters, saved queries save the 'highlight' and 'invert' toggles as part of their states. This makes it possible for a user to save a saved query with highlights and invert sates on or off.
Problem
However, saving that state indiscriminately also produces a few issues:
- If the saved query is empty, for example, it will still save the state of the highlight/invert toggles. So, if the user manually clears all filters from the filter area but their highlight button is toggled "on" the query won't be recognized as saved even though as far as the user is concerned, what they are seeing is an empty query like they saved before. The same is true for the invert toggle.
- If the user added highlights into the system, and hten toggled the highlight state off, what they actually see on the screen is filter query without highlights but the inner state still retains the highlighted filters, just with the highlight toggle on "off" state. This means a few things:
- First, it means that the comparison query will not match if the user compares to a new state that never had highlights in them.
- Second, (and this might be a pro or a con, depending on how one looks at it) when the user reloads this saved query and toggles the "highlight" to "true" the previous highlights will appear. This might be a good thing while the user is in the same session as the toggling-off of the highlight button, but it might be considered "noise" if the user reloads a query they saved without the highlights.
(The above is also the same problem for the invert toggle in relation to namespace filters)
Proposal
To fix this, I propose the following change to how we save saved queries:
- If the user saved a query that has the highlight toggle in an "off" state, then the saved query should also ignore the highlights completely and save itself as if no highlights were ever chosen.
- This means that while the user will be able to toggle the highlight button on and see their previously selected highlights in their current session, once they reload the saved query, the highlight selection is gone. It might seem weird, but it does follow saving what the user *literally* picked rather than an invisible state of the system.
- If the user saves a query that has the highlight button in an "on" state but there are no current highlighted filters chosen then the highlight filter will be set to 'off' and the saved query will be saved without highlights.
- This means that we might lose the 'show highlight' button state for this saved query, but it will retain the visible state of the system as before.
- The two rules above will be reproduced the same for the 'invert' button if it's on or off regarding whether there are namespaces chosen.
- Followup: When we compare queries to current state, we use the same rules as above (if no highlights, highlight toggle is deleted from the comparison object, same for invert if no namespaces)
- This will mean that the saved query will be compared to the visible state of the system and not whatever hidden "behind the scene" state that the model retained due to the user playing around or using different highlights or invert methods, or just forgetting about the toggle buttons altogether.