Browse Source

New global search

master
Igor Zhukov 9 years ago
parent
commit
dd423ff3cd
  1. 2
      app/js/lib/config.js
  2. 4
      app/js/lib/schema.tl.txt
  3. 60
      app/js/messages_manager.js

2
app/js/lib/config.js

File diff suppressed because one or more lines are too long

4
app/js/lib/schema.tl.txt

@ -481,7 +481,7 @@ updates.channelDifferenceTooLong#5e167646 flags:# final:flags.0?true pts:int tim @@ -481,7 +481,7 @@ updates.channelDifferenceTooLong#5e167646 flags:# final:flags.0?true pts:int tim
updates.channelDifference#2064674e flags:# final:flags.0?true pts:int timeout:flags.1?int new_messages:Vector<Message> other_updates:Vector<Update> chats:Vector<Chat> users:Vector<User> = updates.ChannelDifference;
channelMessagesFilterEmpty#94d42ee7 = ChannelMessagesFilter;
channelMessagesFilter#cd77d957 flags:# important_only:flags.0?true ranges:Vector<MessageRange> = ChannelMessagesFilter;
channelMessagesFilter#cd77d957 flags:# important_only:flags.0?true exclude_new_messages:flags.1?true ranges:Vector<MessageRange> = ChannelMessagesFilter;
channelMessagesFilterCollapsed#fa01232e = ChannelMessagesFilter;
channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant;
@ -653,7 +653,7 @@ channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats; @@ -653,7 +653,7 @@ channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates;
channels.editAbout#13e27f1e channel:InputChannel about:string = Bool;
channels.editAdmin#52b16962 channel:InputChannel user_id:InputUser role:ChannelParticipantRole = Bool;
channels.editAdmin#eb7611d0 channel:InputChannel user_id:InputUser role:ChannelParticipantRole = Updates;
channels.editTitle#566decd0 channel:InputChannel title:string = Updates;
channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates;
channels.toggleComments#aaa29e88 channel:InputChannel enabled:Bool = Updates;

60
app/js/messages_manager.js

@ -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,24 +788,50 @@ angular.module('myApp.services') @@ -788,24 +788,50 @@ angular.module('myApp.services')
});
}
var flags = 0;
if (AppPeersManager.isChannel(peerID)) {
flags |= 1;
var apiPromise;
if (peerID || !query) {
var flags = 0;
if (AppPeersManager.isChannel(peerID) &&
!AppPeersManager.isMegagroup(peerID)) {
flags |= 1;
}
apiPromise = MtpApiManager.invokeApi('messages.search', {
flags: flags,
peer: inputPeer,
q: query || '',
filter: inputFilter || {_: 'inputMessagesFilterEmpty'},
min_date: 0,
max_date: 0,
limit: limit || 20,
max_id: maxID || 0
}, {
timeout: 300,
noErrorBox: true
});
} 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 MtpApiManager.invokeApi('messages.search', {
flags: flags,
peer: inputPeer,
q: query || '',
filter: inputFilter || {_: 'inputMessagesFilterEmpty'},
min_date: 0,
max_date: 0,
limit: limit || 20,
max_id: maxID || 0
}, {
timeout: 300,
noErrorBox: true
}).then(function (searchResult) {
return apiPromise.then(function (searchResult) {
AppUsersManager.saveApiUsers(searchResult.users);
AppChatsManager.saveApiChats(searchResult.chats);
saveMessages(searchResult.messages);

Loading…
Cancel
Save