WikiWatershed / model-my-watershed

The web application front end for Model My Watershed.
https://modelmywatershed.org
Apache License 2.0
57 stars 31 forks source link

Queue multiple POST and PUT requests #451

Open rajadain opened 9 years ago

rajadain commented 9 years ago

This is proposed as a generalized extension to #448, more for the sake of record than urgent need of implementation.

There are use cases, for example when the user is on a flaky internet connection, when the user interface is faster than the network. In such cases, it is possible for the user to make multiple modifications to a project or scenario, while the individual POST requests are still in transit. Instead of firing them all at once and hoping they sort themselves out, we should queue ones with explicit relationships.

For example, if a user adds a new scenario and quickly makes a change to it, two POST requests are fired instead of a POST and a PUT, resulting in an error response of "The fields name, project must make a unique set." and an unpredictable outcome of which version was saved: the original or the one with changes.

Consider making a generalized approach that queues multiple POSTs, and converts them into PUTs after the first is returned successfully, or tries the next one if it fails. If there are multiple PUTs, it might either queue them as well or execute only the last one.

rajadain commented 9 years ago

This may end up being a big card that needs more thought than is provided in the initial description above.

kdeloach commented 9 years ago

I would be in favor of...

I mocked up a proof on concept for how we could wire up UI event locking http://jsfiddle.net/kdeloach/qz1d1cw9/ but I would like to put more thought into a better solution.

lliss commented 9 years ago

See https://github.com/WikiWatershed/model-my-watershed/pull/577 for another place where this was becoming a problem. With the fix described in this PR in place we should be able to revert #577 and clean up the code here: https://github.com/WikiWatershed/model-my-watershed/blob/4f4d321792d447d0241ac3d3a7890fbce233012d/src/mmw/js/src/modeling/models.js#L151 and https://github.com/WikiWatershed/model-my-watershed/blob/4f4d321792d447d0241ac3d3a7890fbce233012d/src/mmw/js/src/modeling/models.js#L303