Browse Source

fixed global search

master
Igor Zhukov 9 years ago
parent
commit
a9e95c38ab
  1. 6
      app/js/controllers.js
  2. 8
      app/js/messages_manager.js

6
app/js/controllers.js

@ -826,7 +826,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (searchMessages) { if (searchMessages) {
searchTimeoutPromise = (force || maxID) ? $q.when() : $timeout(angular.noop, 500); searchTimeoutPromise = (force || maxID) ? $q.when() : $timeout(angular.noop, 500);
return searchTimeoutPromise.then(function () { 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) { if (curJump != jump) {
return $q.reject(); return $q.reject();
} }
@ -2614,7 +2614,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return; 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) { if (searchCachedResult.history.indexOf($scope.messageID) >= 0) {
list = searchCachedResult.history; list = searchCachedResult.history;
maxID = list[list.length - 1]; maxID = list[list.length - 1];
@ -2666,7 +2666,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
function loadMore () { function loadMore () {
if (loadingPromise) return loadingPromise; 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) { if (searchResult.history.length) {
maxID = searchResult.history[searchResult.history.length - 1]; maxID = searchResult.history[searchResult.history.length - 1];
list = list.concat(searchResult.history); list = list.concat(searchResult.history);

8
app/js/messages_manager.js

@ -197,7 +197,7 @@ angular.module('myApp.services')
var dialog = dialogs[len - 1]; var dialog = dialogs[len - 1];
var index = dialog.index; var index = dialog.index;
if (index) { if (index) {
offsetDate = Math.ceil(index / 0x10000); offsetDate = Math.ceil(index / 0x10000) + serverTimeOffset;
offsetID = dialog.top_message; offsetID = dialog.top_message;
offsetPeerID = dialog.peerID; offsetPeerID = dialog.peerID;
} }
@ -863,8 +863,9 @@ angular.module('myApp.services')
var offsetPeerID = 0; var offsetPeerID = 0;
var offsetID = 0; var offsetID = 0;
var offsetMessage = maxID && getMessage(maxID); var offsetMessage = maxID && getMessage(maxID);
if (offsetMessage && offsetMessage.date) { if (offsetMessage && offsetMessage.date) {
offsetDate = offsetMessage.date; offsetDate = offsetMessage.date + serverTimeOffset;
offsetID = offsetMessage.id; offsetID = offsetMessage.id;
offsetPeerID = getMessagePeer(offsetMessage); offsetPeerID = getMessagePeer(offsetMessage);
} }
@ -2524,8 +2525,9 @@ angular.module('myApp.services')
historyStorage = historiesStorage[peerID]; historyStorage = historiesStorage[peerID];
if (update._ == 'updateNewChannelMessage' && if (update._ == 'updateNewChannelMessage' &&
!AppChatsManager.isMegagroup(-peerID) &&
!(message.flags & 16 || message.flags & 2 || (message.flags & 256) == 0)) { !(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; break;
} }

Loading…
Cancel
Save