@ -602,7 +602,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
} )
} )
. service ( 'AppMessagesManager' , function ( $q , $rootScope , $location , $filter , ApiUpdatesManager , AppUsersManager , AppChatsManager , AppPeersManager , AppPhotosManager , AppVideoManager , AppDocsManager , AppAudioManager , MtpApiManager , MtpApiFileManager , RichTextProcessor , NotificationsManager , SearchIndexManager , PeersSelectService , Storage , _ ) {
. service ( 'AppMessagesManager' , function ( $q , $rootScope , $location , $filter , ApiUpdatesManager , AppUsersManager , AppChatsManager , AppPeersManager , AppPhotosManager , AppVideoManager , AppDocsManager , AppAudioManager , MtpApiManager , MtpApiFileManager , RichTextProcessor , NotificationsManager , SearchIndexManager , PeersSelectService , Storage , FileManager , _ ) {
var messagesStorage = { } ;
var messagesStorage = { } ;
var messagesForHistory = { } ;
var messagesForHistory = { } ;
@ -1883,8 +1883,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
notification . tag = peerString ;
notification . tag = peerString ;
if ( notificationPhoto . location && ! notificationPhoto . location . empty ) {
if ( notificationPhoto . location && ! notificationPhoto . location . empty ) {
MtpApiFileManager . downloadSmallFile ( notificationPhoto . location , notificationPhoto . size ) . then ( function ( url ) {
MtpApiFileManager . downloadSmallFile ( notificationPhoto . location , notificationPhoto . size ) . then ( function ( blob ) {
notification . image = url ;
notification . image = FileManager . getUrl ( blob , 'image/jpeg' ) ;
if ( message . unread ) {
if ( message . unread ) {
NotificationsManager . notify ( notification ) ;
NotificationsManager . notify ( notification ) ;
@ -2337,7 +2337,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
fullPhotoSize . location . dc _id , inputFileLocation , fullPhotoSize . size , {
fullPhotoSize . location . dc _id , inputFileLocation , fullPhotoSize . size , {
mime : mimeType ,
mime : mimeType ,
toFileEntry : writableFileEntry
toFileEntry : writableFileEntry
} ) . then ( function ( url ) {
} ) . then ( function ( ) {
// console.log('file save done');
// console.log('file save done');
} , function ( e ) {
} , function ( e ) {
console . log ( 'photo download failed' , e ) ;
console . log ( 'photo download failed' , e ) ;
@ -2346,8 +2346,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} , function ( ) {
} , function ( ) {
MtpApiFileManager . downloadFile (
MtpApiFileManager . downloadFile (
fullPhotoSize . location . dc _id , inputFileLocation , fullPhotoSize . size , { mime : mimeType }
fullPhotoSize . location . dc _id , inputFileLocation , fullPhotoSize . size , { mime : mimeType }
) . then ( function ( url ) {
) . then ( function ( blob ) {
FileManager . download ( url , mimeType , fileName ) ;
FileManager . download ( blob , mimeType , fileName ) ;
} , function ( e ) {
} , function ( e ) {
console . log ( 'photo download failed' , e ) ;
console . log ( 'photo download failed' , e ) ;
} ) ;
} ) ;
@ -2487,6 +2487,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
function downloadVideo ( videoID , toFileEntry ) {
function downloadVideo ( videoID , toFileEntry ) {
var video = videos [ videoID ] ,
var video = videos [ videoID ] ,
historyVideo = videosForHistory [ videoID ] || video || { } ,
historyVideo = videosForHistory [ videoID ] || video || { } ,
mimeType = video . mime _type || 'video/ogg' ,
inputFileLocation = {
inputFileLocation = {
_ : 'inputVideoFileLocation' ,
_ : 'inputVideoFileLocation' ,
id : videoID ,
id : videoID ,
@ -2496,11 +2497,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
historyVideo . progress = { enabled : ! historyVideo . downloaded , percent : 1 , total : video . size } ;
historyVideo . progress = { enabled : ! historyVideo . downloaded , percent : 1 , total : video . size } ;
var downloadPromise = MtpApiFileManager . downloadFile ( video . dc _id , inputFileLocation , video . size , {
var downloadPromise = MtpApiFileManager . downloadFile ( video . dc _id , inputFileLocation , video . size , {
mime : video . mime _type || 'video/ogg' ,
mime : mimeType ,
toFileEntry : toFileEntry
toFileEntry : toFileEntry
} ) ;
} ) ;
downloadPromise . then ( function ( url ) {
downloadPromise . then ( function ( blob ) {
var url = FileManager . getUrl ( blob , mimeType ) ;
delete historyVideo . progress ;
delete historyVideo . progress ;
historyVideo . url = $sce . trustAsResourceUrl ( url ) ;
historyVideo . url = $sce . trustAsResourceUrl ( url ) ;
historyVideo . downloaded = true ;
historyVideo . downloaded = true ;
@ -2533,8 +2535,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
downloadVideo ( videoID , writableFileEntry ) ;
downloadVideo ( videoID , writableFileEntry ) ;
}
}
} , function ( ) {
} , function ( ) {
downloadVideo ( videoID ) . then ( function ( url ) {
downloadVideo ( videoID ) . then ( function ( blob ) {
FileManager . download ( url , mimeType , fileName ) ;
FileManager . download ( blob , mimeType , fileName ) ;
} ) ;
} ) ;
} ) ;
} ) ;
}
}
@ -2606,7 +2608,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
doc . thumb = thumb ;
doc . thumb = thumb ;
doc . canDownload = ! ( window . chrome && chrome . fileSystem && chrome . fileSystem . chooseEntry ) ;
doc . canDownload = ! ( window . chrome && chrome . fileSystem && chrome . fileSystem . chooseEntry ) ;
doc . withPreview = doc . canDownload && doc . mime _type . match ( /^(image\/|application\/pdf )/ ) ? 1 : 0 ;
doc . withPreview = doc . canDownload && doc . mime _type . match ( /^(image\/)/ ) ? 1 : 0 ;
if ( isGif && doc . thumb ) {
if ( isGif && doc . thumb ) {
doc . isSpecial = 'gif' ;
doc . isSpecial = 'gif' ;
@ -2654,7 +2656,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
toFileEntry : toFileEntry
toFileEntry : toFileEntry
} ) ;
} ) ;
downloadPromise . then ( function ( url ) {
downloadPromise . then ( function ( blob ) {
var url = FileManager . getUrl ( blob , doc . mime _type ) ;
delete historyDoc . progress ;
delete historyDoc . progress ;
historyDoc . url = $sce . trustAsResourceUrl ( url ) ;
historyDoc . url = $sce . trustAsResourceUrl ( url ) ;
historyDoc . downloaded = true ;
historyDoc . downloaded = true ;
@ -2698,8 +2701,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
downloadDoc ( docID , writableFileEntry ) ;
downloadDoc ( docID , writableFileEntry ) ;
}
}
} , function ( ) {
} , function ( ) {
downloadDoc ( docID ) . then ( function ( url ) {
downloadDoc ( docID ) . then ( function ( blob ) {
FileManager . download ( url , doc . mime _type , doc . file _name ) ;
FileManager . download ( blob , doc . mime _type , doc . file _name ) ;
} ) ;
} ) ;
} ) ;
} ) ;
}
}
@ -2755,6 +2758,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
function downloadAudio ( audioID , toFileEntry ) {
function downloadAudio ( audioID , toFileEntry ) {
var audio = audios [ audioID ] ,
var audio = audios [ audioID ] ,
historyAudio = audiosForHistory [ audioID ] || audio || { } ,
historyAudio = audiosForHistory [ audioID ] || audio || { } ,
mimeType = audio . mime _type || 'audio/ogg' ,
inputFileLocation = {
inputFileLocation = {
_ : 'inputAudioFileLocation' ,
_ : 'inputAudioFileLocation' ,
id : audioID ,
id : audioID ,
@ -2764,11 +2768,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
historyAudio . progress = { enabled : ! historyAudio . downloaded , percent : 1 , total : audio . size } ;
historyAudio . progress = { enabled : ! historyAudio . downloaded , percent : 1 , total : audio . size } ;
var downloadPromise = MtpApiFileManager . downloadFile ( audio . dc _id , inputFileLocation , audio . size , {
var downloadPromise = MtpApiFileManager . downloadFile ( audio . dc _id , inputFileLocation , audio . size , {
mime : audio . mime _type || 'audio/ogg' ,
mime : mimeType ,
toFileEntry : toFileEntry
toFileEntry : toFileEntry
} ) ;
} ) ;
downloadPromise . then ( function ( url ) {
downloadPromise . then ( function ( blob ) {
var url = FileManager . getUrl ( blob , mimeType ) ;
delete historyAudio . progress ;
delete historyAudio . progress ;
historyAudio . url = $sce . trustAsResourceUrl ( url ) ;
historyAudio . url = $sce . trustAsResourceUrl ( url ) ;
historyAudio . downloaded = true ;
historyAudio . downloaded = true ;
@ -2801,8 +2806,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
downloadAudio ( audioID , writableFileEntry ) ;
downloadAudio ( audioID , writableFileEntry ) ;
}
}
} , function ( ) {
} , function ( ) {
downloadAudio ( audioID ) . then ( function ( url ) {
downloadAudio ( audioID ) . then ( function ( blob ) {
FileManager . download ( url , mimeType , fileName ) ;
FileManager . download ( blob , mimeType , fileName ) ;
} ) ;
} ) ;
} ) ;
} ) ;
}
}