diff --git a/public/javascripts/angular-controller.js b/public/javascripts/angular-controller.js index fe28f70..db41fa1 100644 --- a/public/javascripts/angular-controller.js +++ b/public/javascripts/angular-controller.js @@ -44,12 +44,11 @@ angular.module('quassel') function updateMessages() { if ($scope.buffer) { - var it = $scope.buffer.messages.values(); - var messageItem = it.next(); var messages = []; - while(!messageItem.done) { - messages.push(messageItem.value); - messageItem = it.next(); + if ($scope.buffer.messages.__mapValuesData__) { + messages = $scope.buffer.messages.__mapValuesData__; + } else { + messages = Array.from($scope.buffer.messages.values()); } $scope.messages = insertDayChangeMessagesAndApplyIgnoreList(messages, $scope.buffer); $scope.buffer.ignoreListRevision = $ignore.getRevision(); @@ -330,12 +329,8 @@ angular.module('quassel') $scope.buffer = channel; if ($scope.buffer !== null) { updateMessages(); - var id = 0; - channel.messages.forEach(function(val) { - if (val.id > id) id = val.id; - }); $('#messagebox').focus(); - $quassel.markBufferAsRead(channel.id, id); + $quassel.markBufferAsRead(channel.id, channel._lastMessageId); } }; diff --git a/public/javascripts/angular-directive.js b/public/javascripts/angular-directive.js index 7c4d05b..a43cdf4 100644 --- a/public/javascripts/angular-directive.js +++ b/public/javascripts/angular-directive.js @@ -414,37 +414,34 @@ angular.module('quassel') }; }]) .directive('scrollme', [function () { - var parent = $("ul.backlog")[0]; var promise = null; - var heightsum = 0; + var subjects = []; return { link: function (scope, element, attr) { + var parent = $(attr.scrollme)[0]; clearTimeout(promise); - if (element.is(':last-child')) { - heightsum += element.height(); + if (parent.lastElementChild.isEqualNode(element[0])) { + subjects.push(element[0]); promise = setTimeout(function(){ - if (!element.is(':hidden')) { - if (parent.offsetHeight + parent.scrollTop + heightsum + 10 >= parent.scrollHeight) { - parent.scrollTop = parent.scrollHeight; - heightsum = 0; - } + var cumulativeHeight = 0; + for (var i=0; i