diff --git a/app/js/lib/mtproto_wrapper.js b/app/js/lib/mtproto_wrapper.js index 69d29b4c..1169057d 100644 --- a/app/js/lib/mtproto_wrapper.js +++ b/app/js/lib/mtproto_wrapper.js @@ -492,6 +492,7 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto']) }, { dcID: dcID, fileDownload: true, + singleInRequest: true, createNetworker: true }); }, 2).then(function (result) { diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index 87d1e708..98a35a20 100644 --- a/app/js/lib/ng_utils.js +++ b/app/js/lib/ng_utils.js @@ -40,7 +40,12 @@ angular.module('izhukov.utils', []) return {then: function (cb) { return cb(result); }}; - } + }, + reject: function (result) { + return {then: function (cb, badcb) { + return badcb(result); + }}; + }, } }) @@ -109,7 +114,7 @@ angular.module('izhukov.utils', []) function chooseSaveFile (fileName, ext, mimeType) { if (!$window.chrome || !chrome.fileSystem || !chrome.fileSystem.chooseEntry) { - return $q.reject(); + return qSync.reject(); }; var deferred = $q.defer(); diff --git a/app/js/services.js b/app/js/services.js index ea373ab9..32fd1c49 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -2610,7 +2610,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }) -.service('AppVideoManager', function ($sce, $rootScope, $modal, $window, MtpApiFileManager, AppUsersManager, FileManager) { +.service('AppVideoManager', function ($sce, $rootScope, $modal, $window, MtpApiFileManager, AppUsersManager, FileManager, qSync) { var videos = {}, videosForHistory = {}, windowW = $(window).width(), @@ -2736,6 +2736,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) access_hash: video.access_hash }; + if (historyVideo.downloaded && !toFileEntry) { + var cachedBlob = MtpApiFileManager.getCachedFile(inputFileLocation); + if (cachedBlob) { + return qSync.when(cachedBlob); + } + } + historyVideo.progress = {enabled: !historyVideo.downloaded, percent: 1, total: video.size}; var downloadPromise = MtpApiFileManager.downloadFile(video.dc_id, inputFileLocation, video.size, {