parent
b65b932dbf
commit
fb93cb503e
@ -1273,6 +1273,12 @@ img.im_message_document_thumb {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.im_message_media_progress_cancel {
|
||||
font-size: 11px;
|
||||
margin-left: 10px;
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
.tg_up_progress,
|
||||
.tg_down_progress {
|
||||
height: 5px;
|
||||
|
@ -819,7 +819,9 @@ angular.module('myApp.directives', ['myApp.filters'])
|
||||
}
|
||||
}
|
||||
|
||||
var promise = MtpApiFileManager.downloadFile($scope.video.dc_id, inputLocation, $scope.video.size, null, {mime: 'video/mp4'}).then(function (url) {
|
||||
var downloadPromise = MtpApiFileManager.downloadFile($scope.video.dc_id, inputLocation, $scope.video.size, null, {mime: 'video/mp4'});
|
||||
|
||||
downloadPromise.then(function (url) {
|
||||
$scope.progress.enabled = false;
|
||||
// $scope.progress = {enabled: true, percent: 50};
|
||||
$scope.player.hasQuicktime = hasQt;
|
||||
@ -841,7 +843,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
promise.cancel();
|
||||
downloadPromise.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ function pqPrimeFactorization (pqBytes) {
|
||||
try {
|
||||
result = pqPrimeLong(goog.math.Long.fromString(what.toString(16), 16));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error('Pq long Exception', e);
|
||||
};
|
||||
// console.timeEnd('PQ long');
|
||||
}
|
||||
@ -2931,8 +2931,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
|
||||
resolved = false,
|
||||
cacheFileWriter,
|
||||
errorHandler = function (error) {
|
||||
console.error(error);
|
||||
// console.log('fail');
|
||||
// console.error('Dl Error', error);
|
||||
deferred.reject(error);
|
||||
if (cacheFileWriter) cacheFileWriter.truncate(0);
|
||||
errorHandler = angular.noop;
|
||||
@ -3015,8 +3014,10 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
|
||||
resolved = true;
|
||||
deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL());
|
||||
} else {
|
||||
// setTimeout(function () {
|
||||
console.log('File bad size', file, size);
|
||||
cachedFs.root.getFile(fileName, {create: true}, saveToFileEntry, errorHandler)
|
||||
// }, 10000);
|
||||
}
|
||||
}, errorHandler);
|
||||
}, function () {
|
||||
@ -3144,7 +3145,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
|
||||
var fileID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
|
||||
deferred = $q.defer(),
|
||||
errorHandler = function (error) {
|
||||
console.error('Error', error);
|
||||
// console.error('Up Error', error);
|
||||
deferred.reject(error);
|
||||
errorHandler = angular.noop;
|
||||
},
|
||||
@ -3205,6 +3206,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
|
||||
}
|
||||
|
||||
deferred.promise.cancel = function () {
|
||||
console.log('cancel upload', canceled, resolved);
|
||||
if (!canceled && !resolved) {
|
||||
canceled = true;
|
||||
errorHandler({type: 'UPLOAD_CANCELED'});
|
||||
|
@ -1214,8 +1214,10 @@ angular.module('myApp.services', [])
|
||||
}
|
||||
|
||||
message.send = function () {
|
||||
var uploaded = false;
|
||||
var promise = MtpApiFileManager.uploadFile(file).then(function (inputFile) {
|
||||
var uploaded = false,
|
||||
uploadPromise = MtpApiFileManager.uploadFile(file);
|
||||
|
||||
uploadPromise.then(function (inputFile) {
|
||||
uploaded = true;
|
||||
var inputMedia;
|
||||
switch (attachType) {
|
||||
@ -1265,22 +1267,15 @@ angular.module('myApp.services', [])
|
||||
toggleError(true);
|
||||
}, function (progress) {
|
||||
// console.log('upload progress', progress);
|
||||
var historyMessage = messagesForHistory[messageID],
|
||||
percent = Math.max(1, Math.floor(100 * progress.done / progress.total));
|
||||
|
||||
media.progress.done = progress.done;
|
||||
media.progress.percent = percent;
|
||||
if (historyMessage) {
|
||||
historyMessage.media.progress.done = progress.done;
|
||||
historyMessage.media.progress.percent = percent;
|
||||
$rootScope.$broadcast('history_update', {peerID: peerID});
|
||||
}
|
||||
media.progress.percent = Math.max(1, Math.floor(100 * progress.done / progress.total));
|
||||
$rootScope.$broadcast('history_update', {peerID: peerID});
|
||||
});
|
||||
|
||||
media.progress.cancel = function () {
|
||||
if (!uploaded) {
|
||||
promise.cancel();
|
||||
cancelPendingMessage(randomID);
|
||||
uploadPromise.cancel();
|
||||
cancelPendingMessage(randomIDS);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1407,12 +1402,19 @@ angular.module('myApp.services', [])
|
||||
function cancelPendingMessage (randomID) {
|
||||
var pendingData = pendingByRandomID[randomID];
|
||||
|
||||
console.log('pending', randomID, pendingData);
|
||||
|
||||
if (pendingData) {
|
||||
var peerID = pendingData[0],
|
||||
tempID = pendingData[1],
|
||||
historyStorage = historiesStorage[peerID],
|
||||
i;
|
||||
|
||||
ApiUpdatesManager.saveUpdate({
|
||||
_: 'updateDeleteMessages',
|
||||
messages: [tempID]
|
||||
});
|
||||
|
||||
for (i = 0; i < historyStorage.pending.length; i++) {
|
||||
if (historyStorage.pending[i] == tempID) {
|
||||
historyStorage.pending.splice(i, 1);
|
||||
@ -1423,10 +1425,6 @@ angular.module('myApp.services', [])
|
||||
delete messagesForHistory[tempID];
|
||||
delete messagesStorage[tempID];
|
||||
|
||||
ApiUpdatesManager.saveUpdate({
|
||||
_: 'updateDeleteMessages',
|
||||
messages: [tempID]
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1533,8 +1531,8 @@ angular.module('myApp.services', [])
|
||||
|
||||
var message = angular.copy(messagesStorage[msgID]) || {id: msgID};
|
||||
|
||||
if (message.progress) {
|
||||
message.progress = messagesStorage[msgID].progress;
|
||||
if (message.media && message.media.progress !== undefined) {
|
||||
message.media.progress = messagesStorage[msgID].media.progress;
|
||||
}
|
||||
|
||||
message.fromUser = AppUsersManager.getUser(message.from_id);
|
||||
@ -1836,13 +1834,22 @@ angular.module('myApp.services', [])
|
||||
|
||||
var historyStorage = historiesStorage[peerID];
|
||||
if (historyStorage !== undefined) {
|
||||
var newHistory = [];
|
||||
var newHistory = [],
|
||||
newPending = [];
|
||||
for (var i = 0; i < historyStorage.history.length; i++) {
|
||||
if (!updatedData.msgs[historyStorage.history[i]]) {
|
||||
newHistory.push(historyStorage.history[i]);
|
||||
}
|
||||
}
|
||||
historyStorage.history = newHistory;
|
||||
|
||||
for (var i = 0; i < historyStorage.pending.length; i++) {
|
||||
if (!updatedData.msgs[historyStorage.pending[i]]) {
|
||||
newPending.push(historyStorage.pending[i]);
|
||||
}
|
||||
}
|
||||
historyStorage.pending = newPending;
|
||||
|
||||
$rootScope.$broadcast('history_delete', {peerID: peerID, msgs: updatedData.msgs});
|
||||
}
|
||||
});
|
||||
@ -2154,16 +2161,21 @@ angular.module('myApp.services', [])
|
||||
extensions: [ext]
|
||||
}]
|
||||
}, function (writableFileEntry) {
|
||||
MtpApiFileManager.downloadFile(video.dc_id, inputFileLocation, video.size, writableFileEntry, {mime: mimeType}).then(function (url) {
|
||||
var downloadPromise = MtpApiFileManager.downloadFile(video.dc_id, inputFileLocation, video.size, writableFileEntry, {mime: mimeType});
|
||||
downloadPromise.then(function (url) {
|
||||
delete historyVideo.progress;
|
||||
console.log('file save done');
|
||||
}, function (e) {
|
||||
console.log('video download failed', e);
|
||||
historyVideo.progress.enabled = false;
|
||||
}, updateDownloadProgress);
|
||||
|
||||
historyVideo.progress.cancel = downloadPromise.cancel;
|
||||
});
|
||||
} else {
|
||||
MtpApiFileManager.downloadFile(video.dc_id, inputFileLocation, video.size, null, {mime: mimeType}).then(function (url) {
|
||||
var downloadPromise = MtpApiFileManager.downloadFile(video.dc_id, inputFileLocation, video.size, null, {mime: mimeType});
|
||||
|
||||
downloadPromise.then(function (url) {
|
||||
delete historyVideo.progress;
|
||||
|
||||
if (popup) {
|
||||
@ -2187,6 +2199,8 @@ angular.module('myApp.services', [])
|
||||
console.log('video download failed', e);
|
||||
historyVideo.progress.enabled = false;
|
||||
}, updateDownloadProgress);
|
||||
|
||||
historyVideo.progress.cancel = downloadPromise.cancel;
|
||||
}
|
||||
};
|
||||
|
||||
@ -2283,16 +2297,22 @@ angular.module('myApp.services', [])
|
||||
extensions: [ext]
|
||||
}]
|
||||
}, function (writableFileEntry) {
|
||||
MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, writableFileEntry, {mime: doc.mime_type}).then(function (url) {
|
||||
var downloadPromise = MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, writableFileEntry, {mime: doc.mime_type});
|
||||
|
||||
downloadPromise.then(function (url) {
|
||||
delete historyDoc.progress;
|
||||
console.log('file save done');
|
||||
}, function (e) {
|
||||
console.log('document download failed', e);
|
||||
historyDoc.progress.enabled = false;
|
||||
}, updateDownloadProgress);
|
||||
|
||||
historyDoc.progress.cancel = downloadPromise.cancel;
|
||||
});
|
||||
} else {
|
||||
MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, null, {mime: doc.mime_type}).then(function (url) {
|
||||
var downloadPromise = MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, null, {mime: doc.mime_type});
|
||||
|
||||
downloadPromise.then(function (url) {
|
||||
delete historyDoc.progress;
|
||||
|
||||
if (popup) {
|
||||
@ -2316,6 +2336,8 @@ angular.module('myApp.services', [])
|
||||
console.log('document download failed', e);
|
||||
historyDoc.progress.enabled = false;
|
||||
}, updateDownloadProgress);
|
||||
|
||||
historyDoc.progress.cancel = downloadPromise.cancel;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2364,7 +2386,9 @@ angular.module('myApp.services', [])
|
||||
$rootScope.$broadcast('history_update');
|
||||
}
|
||||
|
||||
MtpApiFileManager.downloadFile(audio.dc_id, inputFileLocation, audio.size, null, {mime: 'audio/mpeg'}).then(function (url) {
|
||||
var downloadPromise = MtpApiFileManager.downloadFile(audio.dc_id, inputFileLocation, audio.size, null, {mime: 'audio/mpeg'});
|
||||
|
||||
downloadPromise.then(function (url) {
|
||||
delete historyAudio.progress;
|
||||
historyAudio.url = $sce.trustAsResourceUrl(url);
|
||||
historyAudio.autoplay = true;
|
||||
@ -2374,9 +2398,11 @@ angular.module('myApp.services', [])
|
||||
$rootScope.$broadcast('history_update');
|
||||
}, 1000);
|
||||
}, function (e) {
|
||||
console.log('document download failed', e);
|
||||
historyDoc.progress.enabled = false;
|
||||
console.log('audio download failed', e);
|
||||
historyAudio.progress.enabled = false;
|
||||
}, updateDownloadProgress);
|
||||
|
||||
historyAudio.progress.cancel = downloadPromise.cancel;
|
||||
}
|
||||
|
||||
$rootScope.openAudio = openAudio;
|
||||
|
@ -121,12 +121,11 @@
|
||||
<a href="" ng-click="downloadVideo(historyMessage.media.video.id)">Download</a>
|
||||
<a href="" ng-click="openVideo(historyMessage.media.video.id)">Play video</a>
|
||||
</div>
|
||||
<div class="im_message_download_progress_wrap" ng-if="historyMessage.media.video.progress.enabled">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{historyMessage.media.video.progress.percent}}" aria-valuemin="0" aria-valuemax="100" style="width: {{historyMessage.media.video.progress.percent}}%">
|
||||
<span class="sr-only">
|
||||
{{historyMessage.media.video.progress.percent}}% Complete (success)
|
||||
</span>
|
||||
<div class="clearfix cancelable_progress_wrap" ng-if="historyMessage.media.video.progress.enabled">
|
||||
<a class="im_message_media_progress_cancel pull-right" ng-click="historyMessage.media.video.progress.cancel()">Cancel</a>
|
||||
<div class="im_message_download_progress_wrap">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" ng-style="{width: historyMessage.media.video.progress.percent + '%'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -155,9 +154,12 @@
|
||||
<a href="" ng-click="downloadDoc(historyMessage.media.document.id)">Download</a>
|
||||
<a href="" ng-click="downloadDoc(historyMessage.media.document.id, false, true)" bo-if="historyMessage.media.document.withPreview">Open</a>
|
||||
</div>
|
||||
<div class="im_message_download_progress_wrap" ng-if="historyMessage.media.document.progress.enabled">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" ng-style="{width: historyMessage.media.document.progress.percent + '%'}"></div>
|
||||
<div class="clearfix cancelable_progress_wrap" ng-if="historyMessage.media.document.progress.enabled">
|
||||
<a class="im_message_media_progress_cancel pull-right" ng-click="historyMessage.media.document.progress.cancel()">Cancel</a>
|
||||
<div class="im_message_download_progress_wrap">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" ng-style="{width: historyMessage.media.document.progress.percent + '%'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -181,9 +183,12 @@
|
||||
<div class="im_message_audio_actions" ng-if="!historyMessage.media.audio.progress.enabled && !historyMessage.media.audio.url">
|
||||
<a href="" ng-click="openAudio(historyMessage.media.audio.id)">Play</a>
|
||||
</div>
|
||||
<div class="im_message_download_progress_wrap" ng-if="historyMessage.media.audio.progress.enabled">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" ng-style="{width: historyMessage.media.audio.progress.percent + '%'}"></div>
|
||||
<div class="clearfix cancelable_progress_wrap" ng-if="historyMessage.media.audio.progress.enabled">
|
||||
<a class="im_message_media_progress_cancel pull-right" ng-click="historyMessage.media.audio.progress.cancel()">Cancel</a>
|
||||
<div class="im_message_download_progress_wrap">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" ng-style="{width: historyMessage.media.audio.progress.percent + '%'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="im_message_audio_player_wrap" ng-if="historyMessage.media.audio.url">
|
||||
@ -221,10 +226,12 @@
|
||||
<span class="im_message_document_name" bo-bind="historyMessage.media.file_name"></span>
|
||||
<span class="im_message_document_size" ng-if="historyMessage.media.progress" ng-bind="historyMessage.media.progress | formatSizeProgress"></span>
|
||||
</div>
|
||||
<!-- <a href="" class="pull-right" ng-click="historyMessage.media.progress.cancel()">Cancel</a> -->
|
||||
<div class="im_message_download_progress_wrap">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" role="progressbar" ng-style="{width: historyMessage.media.progress.percent + '%'}"></div>
|
||||
<div class="clearfix cancelable_progress_wrap">
|
||||
<a class="im_message_media_progress_cancel pull-right" ng-click="historyMessage.media.progress.cancel()">Cancel</a>
|
||||
<div class="im_message_download_progress_wrap">
|
||||
<div class="progress tg_down_progress">
|
||||
<div class="progress-bar progress-bar-success" role="progressbar" ng-style="{width: historyMessage.media.progress.percent + '%'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user