Refactor chat notifications and the chatNewMessage hook