@@ -1308,8 +1308,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
13081308 selectedCancel ( true )
13091309
13101310 if ( oldDialog . peer &&
1311- oldDialog . peer == newDialog . peer &&
1312- newDialog . messageID ) {
1311+ oldDialog . peer == newDialog . peer &&
1312+ newDialog . messageID ) {
13131313 messageFocusHistory ( )
13141314 } else if ( peerID ) {
13151315 updateHistoryPeer ( true )
@@ -4800,7 +4800,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
48004800 }
48014801 } )
48024802
4803- . controller ( 'ContactsModalController' , function ( $scope , $rootScope , $timeout , $modal , $modalInstance , MtpApiManager , AppUsersManager , ErrorService ) {
4803+ . controller ( 'ContactsModalController' , function ( $scope , $rootScope , $timeout , $modal , $modalInstance , MtpApiManager , AppPeersManager , AppUsersManager , ErrorService ) {
48044804 $scope . contacts = [ ]
48054805 $scope . foundPeers = [ ]
48064806 $scope . search = { }
@@ -4852,20 +4852,25 @@ angular.module('myApp.controllers', ['myApp.i18n'])
48524852 $scope . $broadcast ( 'contacts_change' )
48534853 } )
48544854
4855- if ( query && query . length >= 5 ) {
4855+ if ( query && query . length >= 2 ) {
48564856 $timeout ( function ( ) {
48574857 if ( curJump != jump ) return
48584858 MtpApiManager . invokeApi ( 'contacts.search' , { q : query , limit : 10 } ) . then ( function ( result ) {
48594859 AppUsersManager . saveApiUsers ( result . users )
48604860 if ( curJump != jump ) return
4861- angular . forEach ( result . results , function ( contactFound ) {
4862- var userID = contactFound . user_id
4863- if ( doneIDs . indexOf ( userID ) != - 1 ) return
4861+ var myPeersLen = result . my_results . length
4862+ var foundPeers = result . my_results . concat ( result . results )
4863+ angular . forEach ( foundPeers , function ( peerFound , i ) {
4864+ var peerID = AppPeersManager . getPeerID ( peerFound )
4865+ if ( peerID <= 0 ||
4866+ doneIDs . indexOf ( peerID ) != - 1 ) {
4867+ return
4868+ }
48644869 $scope . contacts . push ( {
4865- userID : userID ,
4866- user : AppUsersManager . getUser ( userID ) ,
4867- peerString : AppUsersManager . getUserString ( userID ) ,
4868- found : true
4870+ userID : peerID ,
4871+ user : AppUsersManager . getUser ( peerID ) ,
4872+ peerString : AppUsersManager . getUserString ( peerID ) ,
4873+ found : i >= myPeersLen
48694874 } )
48704875 } )
48714876 } , function ( error ) {
0 commit comments