From a101ce05adbed1795410d3cf9dcc4d8ccff0504b Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 13 Feb 2015 13:05:00 +0300 Subject: [PATCH] Added unread split for idle tab Closes #666 --- app/js/controllers.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index c6ab1b83..01394586 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -952,10 +952,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) } if (pos > -1) { history = $scope.peerHistories[pos]; - // if (pos) { - // $scope.peerHistories.splice(pos, 1); - // $scope.peerHistories.unshift(history); - // } return history; } history = {peerID: peerID, messages: []}; @@ -1389,7 +1385,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) } // console.log('append', addedMessage); // console.trace(); - history.messages.push(AppMessagesManager.wrapForHistory(addedMessage.messageID)); + var historyMessage = AppMessagesManager.wrapForHistory(addedMessage.messageID); + history.messages.push(historyMessage); if (AppMessagesManager.regroupWrappedHistory(history.messages, -3)) { $scope.$broadcast('messages_regroup'); } @@ -1402,8 +1399,16 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.$broadcast('messages_unread_after'); } - // console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID); - if (!$rootScope.idle.isIDLE) { + // console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID, historyMessage, history.messages[history.messages.length - 2]); + if ($rootScope.idle.isIDLE) { + if (historyMessage.unread && + !historyMessage.out && + !(history.messages[history.messages.length - 2] || {}).unread) { + + $scope.historyUnreadAfter = historyMessage.id; + $scope.$broadcast('messages_unread_after'); + } + } else { $timeout(function () { AppMessagesManager.readHistory($scope.curDialog.inputPeer); });