Browse Source

Improved Safari download performance

master
Igor Zhukov 9 years ago
parent
commit
e7d72196f5
  1. 1
      app/js/lib/mtproto_wrapper.js
  2. 9
      app/js/lib/ng_utils.js
  3. 9
      app/js/services.js

1
app/js/lib/mtproto_wrapper.js

@ -492,6 +492,7 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto']) @@ -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) {

9
app/js/lib/ng_utils.js

@ -40,7 +40,12 @@ angular.module('izhukov.utils', []) @@ -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', []) @@ -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();

9
app/js/services.js

@ -2610,7 +2610,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -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']) @@ -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…
Cancel
Save