Fix potential cursor but and refactor

Cursor bug occurs when we try to set the color before user.avatarColor is
defined.