2015-07-03 04:18:05 +08:00
|
|
|
Template.makeButton.helpers
|
|
|
|
hasGotUnreadMail: (userId) ->
|
2015-07-08 00:25:29 +08:00
|
|
|
chats = getInSession('chats')
|
|
|
|
if chats isnt undefined
|
|
|
|
if userId is "all_chats"
|
2015-07-09 01:09:29 +08:00
|
|
|
for tabs in chats
|
|
|
|
if tabs.gotMail is true
|
|
|
|
return true
|
2015-07-08 00:25:29 +08:00
|
|
|
else if userId is "PUBLIC_CHAT"
|
2015-07-09 01:09:29 +08:00
|
|
|
for tabs in chats
|
|
|
|
if tabs.userId is userId and tabs.gotMail is true
|
|
|
|
return true
|
2015-07-18 05:50:49 +08:00
|
|
|
return false
|
|
|
|
|
|
|
|
getNumberOfUnreadMessages: (userId) ->
|
|
|
|
if userId is "all_chats"
|
|
|
|
return
|
|
|
|
else
|
|
|
|
chats = getInSession('chats')
|
|
|
|
if chats isnt undefined
|
|
|
|
for chat in chats
|
|
|
|
if chat.userId is userId and chat.gotMail
|
|
|
|
if chat.number > 9
|
|
|
|
return "9+"
|
|
|
|
else
|
|
|
|
return chat.number
|
|
|
|
return
|
|
|
|
|
|
|
|
getNotificationClass: (userId) ->
|
|
|
|
if userId is "all_chats"
|
|
|
|
return "unreadChat"
|
|
|
|
if userId is "PUBLIC_CHAT"
|
2015-07-19 09:33:02 +08:00
|
|
|
return "unreadChatNumber"
|