Skip to content

Commit

Permalink
Don't add a date header in rooms without chat
Browse files Browse the repository at this point in the history
  • Loading branch information
dpatti committed Aug 1, 2012
1 parent 4045d3e commit dfa2fea
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions JabbR/Chat.ui.js
Expand Up @@ -99,6 +99,14 @@
return this.tab.hasClass('unread');
};

this.hasMessages = function () {
return this.tab.data('messages');
};

this.updateMessages = function (value) {
this.tab.data('messages', value);
};

this.getUnread = function () {
return $tab.data('unread') || 0;
};
Expand Down Expand Up @@ -1650,8 +1658,12 @@
return $element;
},
appendMessage: function (newMessage, room) {
// Determine if we need to show a new date header
if (!$(newMessage).is('.date-header')) {
// Determine if we need to show a new date header: Two conditions
// for instantly skipping are if this message is a date header, or
// if the room only contains non-chat messages and we're adding a
// non-chat message.
var isMessage = $(newMessage).is('.message');
if (!$(newMessage).is('.date-header') && (isMessage || room.hasMessages())) {
var lastMessage = room.messages.find('li[data-timestamp]').last(),
lastDate = new Date(lastMessage.data('timestamp')),
thisDate = new Date($(newMessage).data('timestamp'));
Expand All @@ -1662,6 +1674,10 @@
}
}

if (isMessage) {
room.updateMessages(true);
}

$(newMessage).appendTo(room.messages);
},
hasFocus: function () {
Expand Down

0 comments on commit dfa2fea

Please sign in to comment.