New function to handle the state change of the refresh button.