diff --git a/app/js/controllers.js b/app/js/controllers.js index 54b0ce5b..22939611 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1018,9 +1018,6 @@ angular.module('myApp.controllers', []) else if (forceRecent) { limit = 10; } - else if (Config.Mobile) { - limit = 20; - } moreActive = false; morePending = false; @@ -1064,6 +1061,9 @@ angular.module('myApp.controllers', []) if ($scope.skippedHistory) { delete message.unread; } + if (historyResult.unreadOffset) { + message.unreadAfter = true; + } peerHistory.messages.push(message); }); peerHistory.messages.reverse(); diff --git a/app/js/directives.js b/app/js/directives.js index 5e194280..8fcfe73c 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -101,29 +101,33 @@ angular.module('myApp.directives', ['myApp.filters']) } }); - if ($scope.historyMessage.unread) { - var deregisterUnreadAfter; - if (!$scope.historyMessage.out) { - var applyUnreadAfter = function () { - if (unreadAfter != ($scope.historyUnreadAfter == $scope.historyMessage.id)) { - unreadAfter = !unreadAfter; - if (unreadAfter) { - if (unreadAfterSplit) { - unreadAfterSplit.show(); - } else { - unreadAfterSplit = $(unreadSplitHtml).prependTo(element); - } + var deregisterUnreadAfter; + if (!$scope.historyMessage.out && + ($scope.historyMessage.unread || $scope.historyMessage.unreadAfter)) { + var applyUnreadAfter = function () { + if ($scope.peerHistory.peerID != $scope.historyPeer.id) { + return; + } + if (unreadAfter != ($scope.historyUnreadAfter == $scope.historyMessage.id)) { + unreadAfter = !unreadAfter; + if (unreadAfter) { + if (unreadAfterSplit) { + unreadAfterSplit.show(); } else { - unreadAfterSplit.hide(); - if (deregisterUnreadAfter) { - deregisterUnreadAfter(); - } + unreadAfterSplit = $(unreadSplitHtml).prependTo(element); + } + } else { + unreadAfterSplit.hide(); + if (deregisterUnreadAfter) { + deregisterUnreadAfter(); } } - }; - applyUnreadAfter(); - deregisterUnreadAfter = $scope.$on('messages_unread_after', applyUnreadAfter); - } + } + }; + applyUnreadAfter(); + deregisterUnreadAfter = $scope.$on('messages_unread_after', applyUnreadAfter); + } + if ($scope.historyMessage.unread) { element.addClass(unreadClass); var deregisterUnread = $scope.$on('messages_read', function () { if (!$scope.historyMessage.unread) { diff --git a/app/js/services.js b/app/js/services.js index f4d16e54..356e2d2d 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -929,6 +929,9 @@ angular.module('myApp.services', []) unreadOffset = unreadCount; } } + else if (Config.Mobile) { + limit = 20; + } } else if (maxID > 0) { offsetNotFound = true;