added some null checks to message.user.id

This commit is contained in:
Henry Oswald 2015-02-16 23:16:38 +00:00
parent 7dd1ab84d5
commit c4b21f3184
2 changed files with 4 additions and 4 deletions

View file

@ -15,7 +15,7 @@ define [
$scope.$on "chat:newMessage", (e, message) ->
if message?
if message.user.id != ide.$scope.user.id
if message?.user?.id != ide.$scope.user.id
if !$scope.ui.chatOpen
$scope.unreadMessages += 1
flashTitle()

View file

@ -18,7 +18,7 @@ define [
justSent = false
ide.socket.on "new-chat-message", (message) =>
if message.user.id == ide.$scope.user.id and justSent
if message?.user?.id == ide.$scope.user.id and justSent
# Nothing to do
else
ide.$scope.$apply () ->
@ -65,7 +65,7 @@ define [
prependMessage = (message) ->
firstMessage = chat.state.messages[0]
shouldGroup = firstMessage? and
firstMessage.user.id == message.user.id and
firstMessage.user.id == message?.user?.id and
firstMessage.timestamp - message.timestamp < TIMESTAMP_GROUP_SIZE
if shouldGroup
firstMessage.timestamp = message.timestamp
@ -86,7 +86,7 @@ define [
lastMessage = chat.state.messages[chat.state.messages.length - 1]
shouldGroup = lastMessage? and
lastMessage.user.id == message.user.id and
lastMessage.user.id == message?.user?.id and
message.timestamp - lastMessage.timestamp < TIMESTAMP_GROUP_SIZE
if shouldGroup
lastMessage.timestamp = message.timestamp