|
|
@ -721,7 +721,7 @@ angular.module('myApp.services') |
|
|
|
lastSearchResults = []; |
|
|
|
lastSearchResults = []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!maxID && !query) { |
|
|
|
if (peerID && !maxID && !query) { |
|
|
|
var historyStorage = historiesStorage[peerID]; |
|
|
|
var historyStorage = historiesStorage[peerID]; |
|
|
|
|
|
|
|
|
|
|
|
if (historyStorage !== undefined && historyStorage.history.length) { |
|
|
|
if (historyStorage !== undefined && historyStorage.history.length) { |
|
|
@ -788,12 +788,15 @@ angular.module('myApp.services') |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var apiPromise; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (peerID || !query) { |
|
|
|
var flags = 0; |
|
|
|
var flags = 0; |
|
|
|
if (AppPeersManager.isChannel(peerID)) { |
|
|
|
if (AppPeersManager.isChannel(peerID) && |
|
|
|
|
|
|
|
!AppPeersManager.isMegagroup(peerID)) { |
|
|
|
flags |= 1; |
|
|
|
flags |= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
apiPromise = MtpApiManager.invokeApi('messages.search', { |
|
|
|
return MtpApiManager.invokeApi('messages.search', { |
|
|
|
|
|
|
|
flags: flags, |
|
|
|
flags: flags, |
|
|
|
peer: inputPeer, |
|
|
|
peer: inputPeer, |
|
|
|
q: query || '', |
|
|
|
q: query || '', |
|
|
@ -805,7 +808,30 @@ angular.module('myApp.services') |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
timeout: 300, |
|
|
|
timeout: 300, |
|
|
|
noErrorBox: true |
|
|
|
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); |
|
|
|
AppUsersManager.saveApiUsers(searchResult.users); |
|
|
|
AppChatsManager.saveApiChats(searchResult.chats); |
|
|
|
AppChatsManager.saveApiChats(searchResult.chats); |
|
|
|
saveMessages(searchResult.messages); |
|
|
|
saveMessages(searchResult.messages); |
|
|
|