From a9e95c38abb068f7c93eb5b9805f3ba122c8430b Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 20 Nov 2015 18:56:43 +0300 Subject: [PATCH] fixed global search --- app/js/controllers.js | 6 +++--- app/js/messages_manager.js | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index c0406e47..a5bccfb2 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -826,7 +826,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (searchMessages) { searchTimeoutPromise = (force || maxID) ? $q.when() : $timeout(angular.noop, 500); return searchTimeoutPromise.then(function () { - return AppMessagesManager.getSearch({_: 'inputPeerEmpty'}, $scope.search.query, {_: 'inputMessagesFilterEmpty'}, maxID).then(function (result) { + return AppMessagesManager.getSearch(false, $scope.search.query, {_: 'inputMessagesFilterEmpty'}, maxID).then(function (result) { if (curJump != jump) { return $q.reject(); } @@ -2614,7 +2614,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) return; } - AppMessagesManager.getSearch(inputPeer, inputQuery, inputFilter, 0, 1000).then(function (searchCachedResult) { + AppMessagesManager.getSearch(peerID, inputQuery, inputFilter, 0, 1000).then(function (searchCachedResult) { if (searchCachedResult.history.indexOf($scope.messageID) >= 0) { list = searchCachedResult.history; maxID = list[list.length - 1]; @@ -2666,7 +2666,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) function loadMore () { if (loadingPromise) return loadingPromise; - return loadingPromise = AppMessagesManager.getSearch(inputPeer, inputQuery, inputFilter, maxID).then(function (searchResult) { + return loadingPromise = AppMessagesManager.getSearch(peerID, inputQuery, inputFilter, maxID).then(function (searchResult) { if (searchResult.history.length) { maxID = searchResult.history[searchResult.history.length - 1]; list = list.concat(searchResult.history); diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index 1250838c..18e0890e 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -197,7 +197,7 @@ angular.module('myApp.services') var dialog = dialogs[len - 1]; var index = dialog.index; if (index) { - offsetDate = Math.ceil(index / 0x10000); + offsetDate = Math.ceil(index / 0x10000) + serverTimeOffset; offsetID = dialog.top_message; offsetPeerID = dialog.peerID; } @@ -863,8 +863,9 @@ angular.module('myApp.services') var offsetPeerID = 0; var offsetID = 0; var offsetMessage = maxID && getMessage(maxID); + if (offsetMessage && offsetMessage.date) { - offsetDate = offsetMessage.date; + offsetDate = offsetMessage.date + serverTimeOffset; offsetID = offsetMessage.id; offsetPeerID = getMessagePeer(offsetMessage); } @@ -2524,8 +2525,9 @@ angular.module('myApp.services') historyStorage = historiesStorage[peerID]; if (update._ == 'updateNewChannelMessage' && + !AppChatsManager.isMegagroup(-peerID) && !(message.flags & 16 || message.flags & 2 || (message.flags & 256) == 0)) { - // we don't support not important messages yet + // we don't support not important messages in channels yet break; }