Instead of keeping global state like this, what about checking the value of the switch when submitting the payload to the API? One less thing to keep in sync...