This change prevents race conditions between state updates and API operations by updating local state immediately before making async calls.
This change prevents race conditions between state updates and API operations by updating local state immediately before making async calls.