diff --git a/web-app/src/ng1/factories/user-paging.service.js b/web-app/src/ng1/factories/user-paging.service.js index af6ce77b7..a8641cd6f 100644 --- a/web-app/src/ng1/factories/user-paging.service.js +++ b/web-app/src/ng1/factories/user-paging.service.js @@ -144,23 +144,21 @@ function UserPagingService(UserService, $q) { return users; } - function search(data, userSearch) { - const previousSearch = data.searchFilter; - - if (previousSearch === '' && userSearch === '') { - return performNoSearch(data); - } else if (previousSearch !== '' && userSearch === '') { - return clearSearch(data); - } else if (previousSearch === userSearch) { - return continueExistingSearch(data); - } else { - return performNewSearch(data, userSearch); - } - } + function search(data, userSearch) { + const previousSearch = data.searchFilter; + + switch (true) { + case previousSearch === '' && userSearch === '': + return performNoSearch(data); + case previousSearch !== '' && userSearch === '': + return clearSearch(data); + case previousSearch === userSearch: + return continueExistingSearch(data); + default: + return performNewSearch(data, userSearch); + } + } - function performNoSearch(data) { - return $q.resolve(data.pageInfo.items); - } function performNoSearch(data) { return $q.resolve(data.pageInfo.items);