cleaning up and changing the color for new chat message notification
This commit is contained in:
parent
49461f4bb3
commit
b506b6a412
@ -253,13 +253,12 @@ Meteor.methods
|
||||
|
||||
#start a clientside-only collection keeping track of the chat tabs
|
||||
@chatTabs = new Meteor.Collection(null)
|
||||
#insert the basic tabs
|
||||
@chatTabs.insert({ userId: "PUBLIC_CHAT", name: "Public", gotMail: false, class: "publicChatTab"})
|
||||
@chatTabs.insert({ userId: "OPTIONS", name: "Options", gotMail: false, class: "optionsChatTab"})
|
||||
console.log "now chatTabs.size is " + @chatTabs.find().count()
|
||||
|
||||
|
||||
#check the chat history of the user and add tabs for the private chats
|
||||
@populateChatTabs = ->
|
||||
console.log "i'm in populateChatTabs"
|
||||
me = getInSession("userId")
|
||||
users = Meteor.Users.find().fetch()
|
||||
myPrivateChats = Meteor.Chat.find({$or: [{'message.from_userid': me, 'message.chat_type': 'PRIVATE_CHAT'},{'message.to_userid': me, 'message.chat_type': 'PRIVATE_CHAT'}] }).fetch()
|
||||
@ -271,19 +270,14 @@ console.log "now chatTabs.size is " + @chatTabs.find().count()
|
||||
if chat.message.from_userid is me
|
||||
uniqueArray.push({userId: chat.message.to_userid, username: chat.message.to_username})
|
||||
|
||||
#for id in uniqueArray
|
||||
#keep unique entries only
|
||||
uniqueArray = uniqueArray.filter((itm, i, a) ->
|
||||
i is a.indexOf(itm)
|
||||
)
|
||||
#insert the unique entries in the collection
|
||||
for u in uniqueArray
|
||||
unless chatTabs.findOne({userId: u.userId})?
|
||||
chatTabs.insert({ userId: u.userId, name: u.username, gotMail: false, class: "privateChatTab"})
|
||||
|
||||
|
||||
|
||||
Handlebars.registerHelper "grabChatTabs", ->
|
||||
chatTabs.find().fetch()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -58,6 +58,9 @@ bottomEntry{
|
||||
#chat-user-list {
|
||||
padding:5px;
|
||||
}
|
||||
.gotUnreadMail{
|
||||
background: #F9DF6B;
|
||||
}
|
||||
#newMessageInput {
|
||||
height:40px;
|
||||
width: 80%;
|
||||
@ -76,11 +79,8 @@ bottomEntry{
|
||||
}
|
||||
.privateChatTab{}
|
||||
.publicChatTab{}
|
||||
.gotUnreadMail{
|
||||
background: #0099FF;
|
||||
}
|
||||
.private-chat-user-box {
|
||||
border: solid 1px grey;
|
||||
border: left 1px grey;
|
||||
padding: 5px;
|
||||
width: 90%;
|
||||
height:60%;
|
||||
|
@ -107,7 +107,7 @@ Template.chatbar.helpers
|
||||
|
||||
msgs
|
||||
|
||||
markNewAsUnread: ->
|
||||
detectUnreadChat: ->
|
||||
#if the current tab is not the same as the tab we just published in
|
||||
Meteor.Chat.find({}).observe({
|
||||
added: (chatMessage) =>
|
||||
@ -116,29 +116,16 @@ Template.chatbar.helpers
|
||||
"PUBLIC_CHAT"
|
||||
else
|
||||
chatMessage.message?.from_userid
|
||||
console.log "size=" + chatTabs.find().count()
|
||||
|
||||
populateChatTabs()
|
||||
|
||||
populateChatTabs() # check if we need to open a new tab
|
||||
destinationTab = findDestinationTab()
|
||||
#Meteor.call('addChatTab', "aaa", "bbb", "ccc")
|
||||
console.log "destination=" + destinationTab
|
||||
|
||||
if destinationTab isnt getInSession "inChatWith"
|
||||
console.log "there should be flashing on:" + destinationTab
|
||||
|
||||
chatTabs.update({userId: destinationTab}, {$set: {gotMail: true}})
|
||||
#myElement = document.querySelector(".tab")
|
||||
#myElement?.style.backgroundColor = "#D93600"
|
||||
|
||||
|
||||
|
||||
#currentTab = document.getElementsByClassName("active")[0].getElementsByTagName("a")[0].id #TODO how can I simplify this?!?
|
||||
})
|
||||
|
||||
|
||||
# When chatbar gets rendered, scroll to the bottom
|
||||
Template.chatbar.rendered = ->
|
||||
Template.chatbar.markNewAsUnread()
|
||||
Template.chatbar.detectUnreadChat()
|
||||
$('#chatbody').scrollTop($('#chatbody')[0]?.scrollHeight)
|
||||
false
|
||||
# Scrolls the message container to the bottom. The number of pixels to scroll down is the height of the container
|
||||
@ -188,8 +175,6 @@ Template.tabButtons.events
|
||||
Meteor.call("deletePrivateChatMessages", getInSession("userId"), @userId)
|
||||
|
||||
|
||||
|
||||
|
||||
return false # stops propogation/prevents default
|
||||
|
||||
'click .optionsChatTab': (event) ->
|
||||
@ -212,7 +197,6 @@ Template.tabButtons.events
|
||||
|
||||
Template.tabButtons.helpers
|
||||
makeTabButton: -> # create tab button for private chat or other such as options
|
||||
console.log "making tab " + JSON.stringify @
|
||||
safeClass = @class.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
safeName = @name.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user