no file storage from WP
This commit is contained in:
parent
3abfb65087
commit
7f6b41e11d
8 changed files with 46 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, gettextCatalog, amMoment) {
|
||||
|
||||
var self = this;
|
||||
self.isCordova = isCordova;
|
||||
self.onGoingProcess = {};
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ function(historicLog, isCordova) {
|
|||
this.isCordova = isCordova;
|
||||
|
||||
this.sendLogs = function() {
|
||||
var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n Copay v' + window.version + ' #' + window.commitHash;
|
||||
body += '\n\n'
|
||||
var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
|
||||
body += '\n\n';
|
||||
body += this.logs.map(function(v) {
|
||||
return v.msg;
|
||||
}).join('\n');
|
||||
|
|
|
|||
|
|
@ -447,11 +447,8 @@ angular
|
|||
});
|
||||
})
|
||||
.run(function($rootScope, $state, $log, gettextCatalog, uriHandler, isCordova, amMoment, profileService) {
|
||||
|
||||
$log.debug('Attaching FastClick');
|
||||
FastClick.attach(document.body);
|
||||
|
||||
|
||||
// Auto-detect browser language
|
||||
var userLang, androidLang;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ angular.module('copayApp.services')
|
|||
root.get = function(k, cb) {
|
||||
root.init(function(err, fs) {
|
||||
if (err) return cb(err);
|
||||
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) {
|
||||
root.getDir(function(err, dir) {
|
||||
if (err) return cb(err);
|
||||
$log.debug(".get: Got main dir:", dir.nativeURL);
|
||||
dir.getFile(k, {
|
||||
create: false,
|
||||
|
|
@ -57,7 +58,8 @@ angular.module('copayApp.services')
|
|||
root.set = function(k, v, cb) {
|
||||
root.init(function(err, fs) {
|
||||
if (err) return cb(err);
|
||||
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) {
|
||||
root.getDir(function(err, dir) {
|
||||
if (err) return cb(err);
|
||||
$log.debug(".set: Got main dir:", dir.nativeURL);
|
||||
dir.getFile(k, {
|
||||
create: true,
|
||||
|
|
@ -90,10 +92,27 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
// See https://github.com/apache/cordova-plugin-file/#where-to-store-files
|
||||
root.getDir = function(cb) {
|
||||
if (!cordova.file) {
|
||||
return cb('Could not write on device storage');
|
||||
}
|
||||
|
||||
var url = cordova.file.dataDirectory;
|
||||
// This could be needed for windows
|
||||
// if (cordova.file === undefined) {
|
||||
// url = 'ms-appdata:///local/';
|
||||
window.resolveLocalFileSystemURL(url, function(dir) {
|
||||
return cb(null, dir);
|
||||
});
|
||||
};
|
||||
|
||||
root.remove = function(k, cb) {
|
||||
root.init(function(err, fs) {
|
||||
if (err) return cb(err);
|
||||
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) {
|
||||
root.getDir(function(err, dir) {
|
||||
if (err) return cb(err);
|
||||
dir.getFile(k, {
|
||||
create: false,
|
||||
}, function(fileEntry) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').value('isChromeApp', window.chrome && chrome.runtime && chrome.runtime.id);
|
||||
angular.module('copayApp.services').value('isChromeApp', !!(window.chrome && chrome.runtime && chrome.runtime.id));
|
||||
|
||||
|
|
|
|||
9
src/js/services/logHeader.js
Normal file
9
src/js/services/logHeader.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.services')
|
||||
.factory('logHeader', function($log, isChromeApp, isCordova) {
|
||||
$log.info('Starting Copay v' + window.version + ' #' + window.commitHash);
|
||||
$log.info('Client: isCordova:', isCordova, 'isChromeApp:', isChromeApp);
|
||||
$log.info('Navigator:', navigator.userAgent);
|
||||
|
||||
return {};
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.services')
|
||||
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, pluginManager, balanceService, applicationService, storageService, bwcService, configService, notificationService, notification, isChromeApp) {
|
||||
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, isChromeApp, isCordova) {
|
||||
|
||||
var root = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.services')
|
||||
.factory('storageService', function(fileStorageService, localStorageService, sjcl, $log, lodash, isCordova) {
|
||||
.factory('storageService', function(logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, isCordova) {
|
||||
|
||||
var root = {};
|
||||
var storage = isCordova ? fileStorageService : localStorageService;
|
||||
|
||||
// File storage is not supported for writting according to
|
||||
// https://github.com/apache/cordova-plugin-file/#supported-platforms
|
||||
var shouldUseFileStorage = isCordova && !isMobile.Windows();
|
||||
$log.debug('Using file storage:', shouldUseFileStorage);
|
||||
|
||||
|
||||
var storage = shouldUseFileStorage ? fileStorageService : localStorageService;
|
||||
|
||||
var getUUID = function(cb) {
|
||||
// TO SIMULATE MOBILE
|
||||
|
|
@ -50,7 +57,7 @@ angular.module('copayApp.services')
|
|||
|
||||
|
||||
root.tryToMigrate = function(cb) {
|
||||
if (!isCordova) return cb();
|
||||
if (!shouldUseFileStorage) return cb();
|
||||
|
||||
localStorageService.get('profile', function(err, str) {
|
||||
if (err) return cb(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue