<commit_before>angular.module("app").controller "DirectoryController", ($scope, $location, $filter, $modal, Blockchain, Wallet, WalletAPI, Utils) ->
    $scope.reg = []
    $scope.genesis_date = ""
    $scope.p =
        currentPage: 0
        pageSize: 20
        numberOfPages: 0
    $scope.q =
        name: ""
    $scope.delegate_active_hash_map = Blockchain.delegate_active_hash_map
    $scope.delegate_inactive_hash_map = Blockchain.delegate_inactive_hash_map


    $scope.accounts = Wallet.accounts
    Wallet.refresh_accounts().then ->
        $scope.accounts = Wallet.accounts

    $scope.$watch ()->
        $scope.q.name
    , ()->
        $scope.p.numberOfPages = Math.ceil(($filter("filter") $scope.reg, $scope.q).length / $scope.p.pageSize)
        $scope.p.currentPage = 0

    Blockchain.get_config().then (config) ->
        $scope.genesis_date = config.genesis_timestamp

    Blockchain.list_accounts().then (reg) ->
        $scope.reg = reg
        $scope.p.numberOfPages = Math.ceil($scope.reg.length / $scope.p.pageSize)

    $scope.contacts = {}
    $scope.refresh_contacts = ->
        $scope.contacts = {}
        angular.forEach Wallet.accounts, (v, k) ->
            if Utils.is_registered(v)
                $scope.contacts[k] = v

    Wallet.refresh_accounts().then ->
        $scope.refresh_contacts()

    $scope.$watchCollection ->
        Wallet.accounts
    , ->
        $scope.refresh_contacts()


    $scope.isFavorite = (r)->
        $scope.contacts[r.name] && $scope.contacts[r.name].is_favorite

    $scope.formatRegDate = (d) ->
        if d == $scope.genesis_date
            "Genesis"
        else
            $filter("prettyDate")(d)

    $scope.addToContactsAndToggleFavorite = (name, address) ->
        Wallet.wallet_add_contact_account(name, address).then ()->
            # TODO: move to wallet service
            Wallet.refresh_accounts().then ()->
                WalletAPI.account_set_favorite(name, !Wallet.accounts[name].is_favorite).then ()->
                    Wallet.refresh_accounts()

    $scope.newContactModal = ->
        console.log '----->newContactModal'
        modal = $modal.open
            templateUrl: "newcontact.html"
            controller: "NewContactController"<commit_msg>fixes Add Contact button in Directory<commit_after>angular.module("app").controller "DirectoryController", ($scope, $location, $filter, $modal, Blockchain, Wallet, WalletAPI, Utils) ->
    $scope.reg = []
    $scope.genesis_date = ""
    $scope.p =
        currentPage: 0
        pageSize: 20
        numberOfPages: 0
    $scope.q =
        name: ""
    $scope.delegate_active_hash_map = Blockchain.delegate_active_hash_map
    $scope.delegate_inactive_hash_map = Blockchain.delegate_inactive_hash_map


    $scope.accounts = Wallet.accounts
    Wallet.refresh_accounts().then ->
        $scope.accounts = Wallet.accounts

    $scope.$watch ()->
        $scope.q.name
    , ()->
        $scope.p.numberOfPages = Math.ceil(($filter("filter") $scope.reg, $scope.q).length / $scope.p.pageSize)
        $scope.p.currentPage = 0

    Blockchain.get_config().then (config) ->
        $scope.genesis_date = config.genesis_timestamp

    Blockchain.list_accounts().then (reg) ->
        $scope.reg = reg
        $scope.p.numberOfPages = Math.ceil($scope.reg.length / $scope.p.pageSize)

    $scope.contacts = {}
    $scope.refresh_contacts = ->
        $scope.contacts = {}
        angular.forEach Wallet.accounts, (v, k) ->
            if Utils.is_registered(v)
                $scope.contacts[k] = v

    Wallet.refresh_accounts().then ->
        $scope.refresh_contacts()

    $scope.$watchCollection ->
        Wallet.accounts
    , ->
        $scope.refresh_contacts()


    $scope.isFavorite = (r)->
        $scope.contacts[r.name] && $scope.contacts[r.name].is_favorite

    $scope.formatRegDate = (d) ->
        if d == $scope.genesis_date
            "Genesis"
        else
            $filter("prettyDate")(d)

    $scope.addToContactsAndToggleFavorite = (name, address) ->
        Wallet.wallet_add_contact_account(name, address).then ()->
            # TODO: move to wallet service
            Wallet.refresh_accounts().then ()->
                WalletAPI.account_set_favorite(name, !Wallet.accounts[name].is_favorite).then ()->
                    Wallet.refresh_accounts()

    $scope.newContactModal = ->
        console.log '----->newContactModal'
        $modal.open
            templateUrl: "newcontact.html"
            controller: "NewContactController"
            resolve:
                addr: null
                action: null
{'fraction_non_alphanumeric': 0.1367893705075147, 'fraction_numerical': 0.0021781746896101066, 'mean_word_length': 2.3299492385786804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '3379880', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1408, 'n_words': 210}