|
|
|
@ -721,7 +721,7 @@ angular.module('myApp.services')
@@ -721,7 +721,7 @@ angular.module('myApp.services')
|
|
|
|
|
lastSearchResults = []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!maxID && !query) { |
|
|
|
|
if (peerID && !maxID && !query) { |
|
|
|
|
var historyStorage = historiesStorage[peerID]; |
|
|
|
|
|
|
|
|
|
if (historyStorage !== undefined && historyStorage.history.length) { |
|
|
|
@ -788,12 +788,15 @@ angular.module('myApp.services')
@@ -788,12 +788,15 @@ angular.module('myApp.services')
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var apiPromise; |
|
|
|
|
|
|
|
|
|
if (peerID || !query) { |
|
|
|
|
var flags = 0; |
|
|
|
|
if (AppPeersManager.isChannel(peerID)) { |
|
|
|
|
if (AppPeersManager.isChannel(peerID) && |
|
|
|
|
!AppPeersManager.isMegagroup(peerID)) { |
|
|
|
|
flags |= 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return MtpApiManager.invokeApi('messages.search', { |
|
|
|
|
apiPromise = MtpApiManager.invokeApi('messages.search', { |
|
|
|
|
flags: flags, |
|
|
|
|
peer: inputPeer, |
|
|
|
|
q: query || '', |
|
|
|
@ -805,7 +808,30 @@ angular.module('myApp.services')
@@ -805,7 +808,30 @@ angular.module('myApp.services')
|
|
|
|
|
}, { |
|
|
|
|
timeout: 300, |
|
|
|
|
noErrorBox: true |
|
|
|
|
}).then(function (searchResult) { |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
var offsetDate = 0; |
|
|
|
|
var offsetPeerID = 0; |
|
|
|
|
var offsetID = 0; |
|
|
|
|
var offsetMessage = maxID && getMessage(maxID); |
|
|
|
|
if (offsetMessage && offsetMessage.date) { |
|
|
|
|
offsetDate = offsetMessage.date; |
|
|
|
|
offsetID = offsetMessage.id; |
|
|
|
|
offsetPeerID = getMessagePeer(offsetMessage); |
|
|
|
|
} |
|
|
|
|
apiPromise = MtpApiManager.invokeApi('messages.searchGlobal', { |
|
|
|
|
q: query, |
|
|
|
|
offset_date: offsetDate, |
|
|
|
|
offset_peer: AppPeersManager.getInputPeerByID(offsetPeerID), |
|
|
|
|
offset_id: getMessageLocalID(offsetID), |
|
|
|
|
limit: limit || 20 |
|
|
|
|
}, { |
|
|
|
|
timeout: 300, |
|
|
|
|
noErrorBox: true |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return apiPromise.then(function (searchResult) { |
|
|
|
|
AppUsersManager.saveApiUsers(searchResult.users); |
|
|
|
|
AppChatsManager.saveApiChats(searchResult.chats); |
|
|
|
|
saveMessages(searchResult.messages); |
|
|
|
|