chat state checking and chat functional on refresh