chat: small cleanup.hmmm, how to handle duplicates? see https://workflowy.com/shared/3ca12ef1-8335-f196-1b74-c1955402c5f5/

This commit is contained in:
Tyler Renelle 2013-05-09 14:29:09 +01:00
parent 8db131dbda
commit 8aee3c7446

View file

@ -90,7 +90,8 @@ module.exports.app = (appExports, model, app) ->
text = model.get input
# Check for non-whitespace characters
return unless /\S/.test text
chat.unshift
message =
id: model.id()
uuid: user.get('id')
contributor: user.get('backer.contributor')
@ -98,8 +99,10 @@ module.exports.app = (appExports, model, app) ->
text: text
user: helpers.username(model.get('_user.auth'), model.get('_user.profile.name'))
timestamp: +new Date
# FIXME how to remove duplicates ?
chat.unshift message, -> chat.remove 200 # keep a max messages cap
model.set(input, '')
chat.remove 200 # keep a max messages cap
model.on 'unshift', '_party.chat', -> $('.chat-message').tooltip()
model.on 'unshift', '_tavern.chat.messages', -> $('.chat-message').tooltip()