openoakland / woeip

A platform for impacted communities to understand their local air quality and advocate for environmental justice.
https://woaq.org
MIT License
29 stars 16 forks source link

As I developer, I want to prevent invalid requests for collections, pollutants, or files #361

Closed TangoYankee closed 3 years ago

TangoYankee commented 3 years ago

Is your feature request related to a problem? Please describe. The map component makes requests whenever the collection of interest changes. However, as part of the State lifecycle, sometimes the data used to make the request is set to placeholder data, which is invalid for requests. This creates erroneous requests and errors. This makes it difficult to manage true errors. It also makes unnecessary work for the server, checking errant requests.

Describe the solution you'd like There are guards in place to prevent calls with errant data. We should also have a state that indicates the values have been reset and we need fresh data.

Describe alternatives you've considered The component could be restructured to make requests by specifically calling functions, rather than watching for state changes. However, the logic for managing these function calls quickly becomes convoluted, given how the state of the application can. Instead, we are able to keep each api call de-coupled from the others by instead coupling them to changes to new valid states.

Also, if we do not reset old data, there will be a lag where the application has old, unwanted data, sitting in the application, while waiting to get the fresh data.

Additional context

Labels

For Developers

Affected Components Map, its children, and tests

Technical Resources MSW for testing

Design Documentation Use existing design language

Testing Outline MSW for testing