diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index 9b9c486c..a9f34537 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -2810,9 +2810,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) { cacheFileWriter = fileWriter; // console.time(fileName + ' ' + (size / 1024)); - // var limit = size > 102400 ? 65536 : 4096; - var limit = size > 30400 ? 524288 : 4096; - // var limit = size > 30400 ? 50480 : 4096; + var limit = 524288; + // var limit = size > 16384 ? 524288 : 51200; var writeFilePromise = $q.when(), writeFileDeferred; for (var offset = 0; offset < size; offset += limit) { diff --git a/app/js/services.js b/app/js/services.js index 9b377dfe..51328fde 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -1880,6 +1880,31 @@ angular.module('myApp.services', []) return photo; } + function preloadPhoto (photoID) { + if (!photos[photoID]) { + return; + } + var photo = photos[photoID], + fullWidth = $(window).width() - 36, + fullHeight = $($window).height() - 150, + fullPhotoSize = choosePhotoSize(photo, fullWidth, fullHeight); + + if (fullPhotoSize && !fullPhotoSize.preloaded) { + fullPhotoSize.preloaded = true; + if (fullPhotoSize.size) { + MtpApiFileManager.downloadFile(fullPhotoSize.location.dc_id, { + _: 'inputFileLocation', + volume_id: fullPhotoSize.location.volume_id, + local_id: fullPhotoSize.location.local_id, + secret: fullPhotoSize.location.secret + }, fullPhotoSize.size); + } else { + MtpApiFileManager.downloadSmallFile(fullPhotoSize.location); + } + } + }; + $rootScope.preloadPhoto = preloadPhoto; + function wrapForFull (photoID) { var photo = wrapForHistory(photoID), fullWidth = $(window).width() - 36, @@ -1940,6 +1965,7 @@ angular.module('myApp.services', []) return { savePhoto: savePhoto, + preloadPhoto: preloadPhoto, wrapForHistory: wrapForHistory, wrapForFull: wrapForFull, openPhoto: openPhoto diff --git a/app/partials/message.html b/app/partials/message.html index 2212afbc..98d17429 100644 --- a/app/partials/message.html +++ b/app/partials/message.html @@ -96,7 +96,7 @@