@@ -357,6 +357,12 @@ public void requestReference(Object parentObject, Object... args) {
357357 sendErrorToObject (args , 0 );
358358 return ;
359359 }
360+ if (parentObject instanceof String && ((String ) parentObject ).startsWith ("avatar_" ) && Utilities .parseLong ((String ) parentObject ) > 0 ) {
361+ long photoId = getRequestedPhotoId (args [0 ]);
362+ if (photoId != 0 ) {
363+ parentKey += "_" + photoId ;
364+ }
365+ }
360366
361367 Requester requester = new Requester ();
362368 requester .args = args ;
@@ -595,9 +601,16 @@ private void requestReferenceFromServer(Object parentObject, String locationKey,
595601 long id = Utilities .parseLong (string );
596602 if (id > 0 ) {
597603 TLRPC .TL_photos_getUserPhotos req = new TLRPC .TL_photos_getUserPhotos ();
598- req .limit = 80 ;
599- req .offset = 0 ;
600- req .max_id = 0 ;
604+ long photoId = getRequestedPhotoId (args [0 ]);
605+ if (photoId != 0 ) {
606+ req .limit = 1 ;
607+ req .offset = -1 ;
608+ req .max_id = photoId ;
609+ } else {
610+ req .limit = 80 ;
611+ req .offset = 0 ;
612+ req .max_id = 0 ;
613+ }
601614 req .user_id = getMessagesController ().getInputUser (id );
602615 getConnectionsManager ().sendRequest (req , (response , error ) -> onRequestComplete (locationKey , parentKey , response , error , true , false ));
603616 } else {
@@ -652,6 +665,16 @@ private void requestReferenceFromServer(Object parentObject, String locationKey,
652665 }
653666 }
654667
668+ private static long getRequestedPhotoId (Object arg ) {
669+ if (arg instanceof TLRPC .TL_inputPhotoFileLocation ) {
670+ return ((TLRPC .TL_inputPhotoFileLocation ) arg ).id ;
671+ }
672+ if (arg instanceof TLRPC .TL_inputPeerPhotoFileLocation ) {
673+ return ((TLRPC .TL_inputPeerPhotoFileLocation ) arg ).photo_id ;
674+ }
675+ return 0 ;
676+ }
677+
655678 private boolean isSameReference (byte [] oldRef , byte [] newRef ) {
656679 return Arrays .equals (oldRef , newRef );
657680 }
0 commit comments