mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
This is pretty black magic to me, but my understanding is that: * When submitting customer forms, we use `$q.all()` on the result of submitting each form asynchronously in order to decide whether to display a success message (no errors) or a failure message. * The value returned for each particular form submission was the return value of either `change.scope.success()` or `change.scope.error()`. These use the `switchClass` factory, which changes a particular DOM element's class to the proper pending/success/error class, but in the success case, it also sets a timeout to remove the class using `$timeout()`, which is a promise, and that was its return value. * Because of the above, `$q.all()` was actually waiting for the `$timeout()` promise to be fulfilled before proceeding. The fix is to not return a `$timeout()` promise from the `switchClass` factory when a timeout is passed, but instead set a timeout on the element, but return the element itself regardless.