Merge pull request #2915 from cmgustavo/bug/reconnect-02

Disabling unnecessary online/offline events for mobile/desktop
This commit is contained in:
Matias Alejo Garcia 2015-06-28 09:11:32 -03:00
commit 801ad1b798
6 changed files with 5 additions and 42 deletions

View file

@ -74,7 +74,7 @@
<div class="oh">
<div class="amount" ng-style="{'background-color':index.backgroundColor}">
<div ng-if="!index.anyOnGoingProcess && !index.notAuthorized">
<div ng-show="index.updateError" ng-click='index.openWallet()'>
<div ng-show="index.updateError" ng-click='index.openWallet(); index.updateTxHistory()'>
<span translate>Could not update Wallet</span>
<br><span translate>Tap to retry</span>
</div>
@ -84,7 +84,7 @@
<br><span translate>Tap to retry</span>
</div>
<div ng-click='index.updateAll(); index.updateTxHistory()' ng-show="!index.updateError && index.walletScanStatus != 'error'">
<div ng-click='index.updateAll(); index.updateTxHistory()' ng-show="!index.updateError && index.walletScanStatus != 'error'">
<strong class="size-36">{{index.totalBalanceStr}}</strong>
<div class="size-14"
ng-if="index.totalBalanceAlternative">

View file

@ -659,26 +659,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.debouncedUpdate();
});
$rootScope.$on('Local/Online', function(event) {
$log.debug('### Online event');
if (self.isOffline) self.debouncedUpdate();
self.isOffline = false;
self.offLineSince = null;
});
self.offLineSince = null;;
$rootScope.$on('Local/Offline', function(event) {
$log.debug('### Offline event');
if (!self.offLineSince) self.offLineSince = Date.now();
if (Date.now() - self.offLineSince > 30000) {
self.isOffline = true;
$timeout(function() {
$rootScope.$apply();
});
}
});
$rootScope.$on('Local/BackupDone', function(event) {
self.needsBackup = false;
storageService.setBackupFlag(self.walletId, function(err) {

View file

@ -46,18 +46,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.resetForm();
});
var disableOnlineListener = $rootScope.$on('Local/Online', function() {
// This is needed then the apps go to sleep
self.bindTouchDown();
});
var disableResumeListener = $rootScope.$on('Local/Resume', function() {
// This is needed then the apps go to sleep
self.bindTouchDown();
});
var disableTabListener = $rootScope.$on('Local/TabChanged', function(e, tab) {
// This will slow down switch, do not add things here!
switch (tab) {
@ -77,7 +70,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
disableTabListener();
disableFocusListener();
disableResumeListener();
disableOnlineListener();
$rootScope.hideMenuBar = false;
});

View file

@ -35,12 +35,6 @@ angular.element(document).ready(function() {
}, 100);
}, false);
// We are not emitting here, since when the BWS socket reconnects,
// update will be triggered
document.addEventListener('offline', function() {
window.location = '#/cordova/offline';
}, false);
// Back button event
document.addEventListener('backbutton', function() {
var loc = window.location;

View file

@ -402,9 +402,6 @@ angular
case 'resume':
$rootScope.$emit('Local/Resume');
break;
case 'offline':
$rootScope.$emit('Local/Offline');
break;
};
$timeout(function() {
$rootScope.$emit('Local/SetTab', 'walletHome', true);

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, isChromeApp, isCordova, gettext) {
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, isChromeApp, isCordova, gettext, nodeWebkit) {
var root = {};
@ -64,14 +64,14 @@ angular.module('copayApp.services')
client.on('reconnect', function() {
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
$rootScope.$emit('Local/Online');
$log.debug('### Online');
}
});
client.on('reconnecting', function() {
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
$rootScope.$emit('Local/Offline');
$log.debug('### Offline');
}
});