diff options
author | Struan Donald <struan@exo.org.uk> | 2013-07-16 12:03:56 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-07-16 12:03:56 +0100 |
commit | cde2222efa4963d9f8458b7dba7b09e3b6b68046 (patch) | |
tree | 5df1392ce3a34519a224ac872d22484697119d2a | |
parent | 54a2ef1075b50fc8759c2179e044ed06f8a88047 (diff) |
use a unique name for each photo added to a report in order to get round
what seem to be iOS caching issues on the photo screen if you add,
remove and then add a photo. Previously it would display the original
photo rather than the new one.
-rw-r--r-- | src/js/files.js | 16 | ||||
-rw-r--r-- | src/js/views/photo.js | 5 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/js/files.js b/src/js/files.js index 583011a..5a4604d 100644 --- a/src/js/files.js +++ b/src/js/files.js @@ -7,7 +7,7 @@ _.extend(FMS, { files: { // move a file at from a uri to a desination directory. maintains file name - moveURI: function (srcURI, dest ) { + moveURI: function (srcURI, newName ) { var fileEntry; return getFileFromURI(srcURI) @@ -22,11 +22,11 @@ return getDirectory(filesystem.root, CONFIG.FILES_DIR, {create: true}); }) .pipe( function(directory) { - return moveFile( fileEntry, directory ); + return moveFile( fileEntry, directory, newName ); }); }, - copyURI: function (srcURI, dest ) { + copyURI: function (srcURI, newName ) { var fileEntry; return getFileFromURI(srcURI) @@ -41,7 +41,7 @@ return getDirectory(filesystem.root, CONFIG.FILES_DIR, {create: true}); }) .pipe( function(directory) { - return copyFile( fileEntry, directory ); + return copyFile( fileEntry, directory, newName ); }); }, @@ -122,7 +122,7 @@ return file.promise(); } - function moveFile (src, dest, options) { + function moveFile (src, dest, newName) { console.log( 'moveing file ' + src.fullPath + ' to ' + dest.fullPath ); @@ -135,13 +135,13 @@ move.resolve( src ); } else { console.log('paths differ so moving'); - src.moveTo( dest, null, move.resolve, move.reject); + src.moveTo( dest, newName, move.resolve, move.reject); } return move.promise(); } - function copyFile (src, dest, options) { + function copyFile (src, dest, newName) { console.log( 'copying file ' + src.fullPath + ' to ' + dest.fullPath ); @@ -154,7 +154,7 @@ copy.resolve( src ); } else { console.log('paths differ so copying'); - src.copyTo( dest, null, copy.resolve, copy.reject); + src.copyTo( dest, newName, copy.resolve, copy.reject); } return copy.promise(); diff --git a/src/js/views/photo.js b/src/js/views/photo.js index 0c308a8..6a2b8f6 100644 --- a/src/js/views/photo.js +++ b/src/js/views/photo.js @@ -48,10 +48,11 @@ // images where they are stored on the filesystem so if you move, and then delete // them, you are moving and deleting the only copy of them which is likely to be // surprising and unwelcome so we copy them instead. + var fileName = CONFIG.NAMESPACE + '_' + this.model.cid + '_' + moment().unix() + '.jpg'; if ( FMS.isAndroid ) { - move = FMS.files.copyURI( imgURI ); + move = FMS.files.copyURI( imgURI, fileName ); } else { - move = FMS.files.moveURI( imgURI ); + move = FMS.files.moveURI( imgURI, fileName ); } var that = this; |