<commit_before>'use strict';

angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, balanceService) {

  $rootScope.title = 'Payment intent'; 

  $scope.open = function() { 
    var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: ModalInstanceCtrl
    });
  };


  // Please note that $modalInstance represents a modal window (instance) dependency.
  // It is not the same as the $modal service used above.

  var ModalInstanceCtrl = function($scope, $modalInstance, identityService) {
    $scope.loading = true;
    $scope.setWallets = function() {
      if (!$rootScope.iden) return;
      var ret = _.filter($rootScope.iden.listWallets(), function(w) {
        return w.balanceInfo && w.balanceInfo.totalBalanceBTC;
      });
      $scope.wallets = ret;
      $scope.loading = false;
    };
    if ($rootScope.iden) {
      var iden = $rootScope.iden;
      iden.on('newWallet', function() {
        $scope.setWallets();
      });
    }
    $scope.ok = function(selectedItem) {
      identityService.setPaymentWallet(selectedItem);
      $modalInstance.close();
    };

    $scope.cancel = function() {
      $rootScope.pendingPayment = null;
      $modalInstance.close();
      $location.path('/homeWallet');
    };
  };

});<commit_msg>Fix delay of listing wallets when payment intent<commit_after>'use strict';

angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, $timeout, balanceService) {

  $rootScope.title = 'Payment intent'; 

  $scope.open = function() { 
    var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: ModalInstanceCtrl
    });
  };


  // Please note that $modalInstance represents a modal window (instance) dependency.
  // It is not the same as the $modal service used above.

  var ModalInstanceCtrl = function($scope, $modalInstance, identityService) {
    $scope.loading = true;
    $scope.setWallets = function() {
      if (!$rootScope.iden) return;
      var ret = _.filter($rootScope.iden.listWallets(), function(w) {
        return w.balanceInfo && w.balanceInfo.totalBalanceBTC;
      });
      $timeout(function() {
        $scope.wallets = ret;
        $scope.loading = false;
        $scope.$digest();
      }, 1);
    };
    if ($rootScope.iden) {
      var iden = $rootScope.iden;
      iden.on('newWallet', function() {
        $scope.setWallets();
      });
    }
    $scope.ok = function(selectedItem) {
      identityService.setPaymentWallet(selectedItem);
      $modalInstance.close();
    };

    $scope.cancel = function() {
      $rootScope.pendingPayment = null;
      $modalInstance.close();
      $location.path('/homeWallet');
    };
  };

});
{'fraction_non_alphanumeric': 0.14341359773371104, 'fraction_numerical': 0.0003541076487252125, 'mean_word_length': 3.0882778581765558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3806798', 'n_tokens_mistral': 834, 'n_tokens_neox': 823, 'n_words': 175}