@@ -179,8 +179,7 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
179179 // continue, when plugins extension failed (just log in console)
180180 . catch ( console . error )
181181 . then ( function ( ) {
182- $scope . listeners . push ( wallet . api . data . on . unauth ( $scope , $scope . updateView ) ) ;
183- $scope . listeners . push ( wallet . api . data . on . auth ( $scope , $scope . updateView ) ) ;
182+ $scope . addListenersOnWallet ( wallet ) ;
184183 csWallet . children . add ( wallet ) ;
185184 UIUtils . loading . hide ( ) ;
186185 $scope . updateView ( ) ;
@@ -230,7 +229,7 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
230229 return $q ( function ( resolve , reject ) {
231230 $translate ( [ 'ACCOUNT.WALLET_LIST.EDIT_POPOVER.TITLE' , 'ACCOUNT.WALLET_LIST.EDIT_POPOVER.HELP' , 'COMMON.BTN_OK' , 'COMMON.BTN_CANCEL' ] )
232231 . then ( function ( translations ) {
233- $scope . formData . name = wallet . data . name || wallet . data . uid || wallet . data . pubkey . substring ( 0 , 8 ) ;
232+ $scope . formData . name = wallet . data . localName || wallet . data . name || wallet . data . uid || wallet . data . pubkey . substring ( 0 , 8 ) ;
234233
235234 // Choose UID popup
236235 $ionicPopup . show ( {
@@ -297,11 +296,11 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
297296
298297 $scope . addListeners = function ( ) {
299298
300- var listeners = [ ] ;
299+ $scope . listeners = [ ] ;
301300
302301 // Auto-update on new block
303302 if ( csSettings . data . walletHistoryAutoRefresh ) {
304- listeners . push (
303+ $scope . listeners . push (
305304 csCurrency . api . data . on . newBlock ( $scope , function ( block ) {
306305 if ( $scope . loading ) return ;
307306 console . debug ( "[wallet-list] Received new block. Will reload list." ) ;
@@ -312,12 +311,16 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
312311 }
313312
314313 // Listen auth events on each wallet
315- $scope . listeners = ( $scope . wallets || [ ] ) . reduce ( function ( res , wallet ) {
316- return res . concat ( [
317- wallet . api . data . on . unauth ( $scope , $scope . updateView ) ,
318- wallet . api . data . on . auth ( $scope , $scope . updateView ) ,
319- ] ) ;
320- } , listeners ) ;
314+ _ . forEach ( $scope . wallets || [ ] , $scope . addListenersOnWallet ) ;
315+ } ;
316+
317+ $scope . addListenersOnWallet = function ( wallet ) {
318+ if ( ! wallet ) return ;
319+ $scope . listeners . push ( wallet . api . data . on . unauth ( $scope , $scope . updateView ) ) ;
320+ $scope . listeners . push ( wallet . api . data . on . auth ( $scope , function ( data , deferred ) {
321+ $timeout ( $scope . updateView ) ;
322+ return deferred ? deferred . resolve ( ) : $q . when ( ) ;
323+ } ) ) ;
321324 } ;
322325
323326 $scope . removeListeners = function ( ) {
0 commit comments