added support for localstorage

This commit is contained in:
Mario Colque 2014-04-01 18:22:07 -03:00
commit c08eda28ab
6 changed files with 96 additions and 38 deletions

View file

@ -4,7 +4,6 @@ angular.module('copay.peer').controller('PeerController',
function($scope, $rootScope, $location, $routeParams, Network) {
$scope.init = function() {
console.log('connecting peer init');
//Network.connect($rootScope.masterId);
};
});

View file

@ -1,28 +1,43 @@
'use strict';
angular.module('copay.signin').controller('SigninController',
function($scope, $rootScope, $location, Network) {
function($scope, $rootScope, $location, Network, Storage) {
var peerData = Storage.get('peerData');
$scope.loading = false;
$rootScope.peerId = null;
$rootScope.peerId = peerData ? peerData.peerId : null;
$scope.create = function() {
$scope.loading = true;
Network.init(function(pid) {
$rootScope.masterId = pid;
$location.path('peer');
Network.init(function() {
$location.path('peer');
});
};
$scope.join = function(cid) {
$scope.loading = true;
Network.init(function() {
Network.connect(cid, function() {
$rootScope.masterId = cid;
$location.path('peer');
});
});
if (cid) {
$rootScope.connectedTo.push(cid);
Network.init(function() {
Network.connect(cid, function() {
$location.path('peer');
});
});
}
};
if (peerData && peerData.peerId) {
console.log('------- reloaded ----------');
console.log(peerData);
$rootScope.peerId = peerData.peerId;
$rootScope.connectedPeers = peerData.connectedPeers;
console.log(peerData.connectedTo[0]);
$scope.join(peerData.connectedTo[0]);
}
});