$scope.searchForUsers = function()

in public/components/punters/punters.js [130:148]


            $scope.searchForUsers = function() {

                const searchText = $scope.searchText.trim();

                if (searchText && searchText.length > 0) {
                    fetch(`/api/people?prefix=${encodeURI(searchText)}`).then(_ => _.json()).then((data) => {
                        if (data && data.length > 0) {
                            $scope.foundUsers = data;
                            //FIXME figure out why it takes so long to render this new `foundUsers` list
                            if ($scope.selectedIndex > $scope.foundUsers.length - 1) {
                                $scope.selectedIndex = $scope.foundUsers.length - 1;
                            }
                        }
                    });
                } else {
                    // TODO check if we need to clear $scope.tokens
                    resetAutocomplete();
                }
            };