Improved Safari download performance
This commit is contained in:
parent
7c6fae062b
commit
e7d72196f5
@ -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) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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, {
|
||||
|
Loading…
Reference in New Issue
Block a user