+Template.userSettings.events
+    "keyup #email": (e) ->
+        Session.set("currentEmailEdited", event.target.value)
+
 UserEmailEdited =
     isEdited: ->
         true

        Notifications.findByUser(Users.currentUser())
        
    inputGroupIfEdited: ->
        if UserEmail.isEdited()
            "input-group"
        else
            ""
            
    isEdited: ->
        UserEmail.isEdited()
        
    glyphClass: ->
        UserEmail.glyphClass()
        
    comment: ->
        UserEmail.comment()

    needVerificationLink: ->
        UserEmail.needVerificationLink()
    needVerificationLink: ->
        false

UserEmail = ->
    if (Users.currentUser()?.emails?.length?) and (Users.currentUser().emails.length > 0)
        email = Users.currentUser().emails[0]
    else
        email = {address: "", verified: undefined}
    currentEmailEdited = Session.get("currentEmailEdited")
    if currentEmailEdited and (currentEmailEdited != email.address)
        UserEmailEdited
    else
        if email.address == ""
            UserEmailAbsent
        else
            if email.verified
                UserEmailVerified
            else UserEmailNonVerified

Template.userSettings.helpers
    reviewCount: -> 
