From 70eca32a641a53acd0ac1b378c3a30f1699d4eb7 Mon Sep 17 00:00:00 2001 From: kimura-developer <136853071+kimura-developer@users.noreply.github.com> Date: Fri, 22 Dec 2023 10:18:02 -0600 Subject: [PATCH] removed duplicate function, search function refactor --- .../src/ng1/factories/user-paging.service.js | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) 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);