clean code

This commit is contained in:
Chneemann 2024-09-03 20:53:28 +02:00
parent fa5bf118de
commit b637993ba1
3 changed files with 5 additions and 9 deletions

View file

@ -134,7 +134,7 @@ export class AddTaskComponent implements OnInit {
searchTask(taskCreator: string): void { searchTask(taskCreator: string): void {
this.updateSearchInput(); this.updateSearchInput();
this.filteredUsers = this.firebaseService this.filteredUsers = this.firebaseService
.getAllUserWithoutGuestCurrentUserAndCreator(taskCreator) .getFilteredUsers(taskCreator)
.filter( .filter(
(user) => (user) =>
user.firstName.toLowerCase().includes(this.searchValue) || user.firstName.toLowerCase().includes(this.searchValue) ||

View file

@ -60,9 +60,7 @@ export class AssignedComponent {
if (this.searchInput) { if (this.searchInput) {
return this.filteredUsers; return this.filteredUsers;
} else { } else {
return this.firebaseService.getAllUserWithoutGuestCurrentUserAndCreator( return this.firebaseService.getFilteredUsers(this.taskCreator);
this.taskCreator
);
} }
} }
} }

View file

@ -113,14 +113,12 @@ export class FirebaseService implements OnDestroy {
return this.getAllUsers().filter((user) => user.initials !== 'G'); return this.getAllUsers().filter((user) => user.initials !== 'G');
} }
getAllUserWithoutGuestCurrentUserAndCreator(taskCreator: string): User[] { getFilteredUsers(taskCreator: string): User[] {
const currentUser = this.getCurrentUserId(); const currentUser = this.getCurrentUserId();
const usersWithoutGuestAndCurrent = this.getAllUsers().filter( const filteredUsers = this.getAllUsers().filter(
(user) => user.initials !== 'G' && user.id !== currentUser (user) => user.initials !== 'G' && user.id !== currentUser
); );
return usersWithoutGuestAndCurrent.filter( return filteredUsers.filter((user) => user.id !== taskCreator);
(user) => user.id !== taskCreator
);
} }
getUserDataFromId(userId: string): User[] { getUserDataFromId(userId: string): User[] {