mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
chat: bad fix for the duplicates messages, but safer than before
This commit is contained in:
parent
1c5d61a617
commit
3461d794a1
1 changed files with 6 additions and 13 deletions
|
|
@ -145,19 +145,12 @@ module.exports.app = (appExports, model, app) ->
|
|||
timestamp: +new Date
|
||||
|
||||
# FIXME - sometimes racer will send many duplicates via chat.unshift. I think because it can't make connection, keeps
|
||||
# trying, but all attempts go through. Unfortunately we can't do chat.set without potentially clobbering other chatters,
|
||||
# and we can't make chat an object without using refLists. hack solution for now is to unshift, and if there are dupes
|
||||
# after we set to unique
|
||||
chat.unshift message, ->
|
||||
messages = chat.get() || []
|
||||
count = messages.length
|
||||
messages =_.uniq messages, true, ((m) -> m?.id) # get rid of dupes
|
||||
#There were a bunch of duplicates, let's clean it up
|
||||
if messages.length != count
|
||||
messages.splice(200)
|
||||
chat.set messages
|
||||
else
|
||||
chat.remove(200)
|
||||
# trying, but all attempts go through. Unfortunately we can't do chat.set without potentially clobbering other chatters
|
||||
messages = chat.get() or []
|
||||
messages.unshift(message)
|
||||
messages.splice(200)
|
||||
chat.set messages
|
||||
|
||||
type = $(el).attr('data-type')
|
||||
model.set '_user.party.lastMessageSeen', chat.get()[0].id if group.get('type') is 'party'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue