Update HTML Chat App to handle correct removal and updating of messages based on event type