Skip to content

Commit

Permalink
removed duplicate function, search function refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kimura-developer authored and restjohn committed Jan 5, 2024
1 parent 34ba1c0 commit 70eca32
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions web-app/src/ng1/factories/user-paging.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 70eca32

Please sign in to comment.