Skip to content

Commit

Permalink
Fix open absences hint bug, replace all .indexOf with .includes #149
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed May 12, 2020
1 parent 1ce3c59 commit 9e50d8e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/open-absences/utils/open-absences-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export function removeOpenAbsences(
(e) =>
!affectedIds.some(
({ lessonIds, personIds }) =>
lessonIds.indexOf(e.LessonRef.Id) !== -1 &&
personIds.indexOf(e.StudentRef.Id) !== -1
lessonIds.includes(e.LessonRef.Id) &&
personIds.includes(e.StudentRef.Id)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class PresenceControlStateService {

hasUnconfirmedAbsences(entry: PresenceControlEntry): Observable<boolean> {
return this.studentIdsWithUnconfirmedAbsences$.pipe(
map((ids) => ids.indexOf(entry.lessonPresence.StudentRef.Id) > 0)
map((ids) => ids.includes(entry.lessonPresence.StudentRef.Id))
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/scroll-position.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class ScrollPositionService implements OnDestroy {
Array.isArray(storeRoute.routeConfig.data.restoreScrollPositionFrom)
? storeRoute.routeConfig.data.restoreScrollPositionFrom
: [];
return restoreScrollPositionFrom.indexOf(this.getPath(forRoute)) !== -1;
return restoreScrollPositionFrom.includes(this.getPath(forRoute));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/services/selection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export abstract class SelectionService<T> {

isSelected$(entry: T): Observable<boolean> {
return this.selection$.pipe(
map((selection) => selection.indexOf(entry) !== -1),
map((selection) => selection.includes(entry)),
distinctUntilChanged()
);
}
Expand All @@ -63,7 +63,7 @@ export abstract class SelectionService<T> {
): ReadonlyArray<T> {
switch (action.type) {
case SelectionActionTypes.ToggleSelection:
if (selection.indexOf(action.payload) === -1) {
if (!selection.includes(action.payload)) {
return [...selection, action.payload];
}
return selection.filter((e) => e !== action.payload);
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/utils/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function searchEntries<T extends Searchable>(
function matchesEntry(term: string): (entry: Searchable) => boolean {
const preparedTerm = normalizeSearchValue(term);
return (entry) =>
normalizeSearchValue(entry.studentFullName).indexOf(preparedTerm) > -1;
normalizeSearchValue(entry.studentFullName).includes(preparedTerm);
}

function normalizeSearchValue(value: string): string {
Expand Down
1 change: 1 addition & 0 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import '@angular/localize/init';
* Polyfills for IE 11
*/
import 'core-js/es/array';
import 'core-js/es/string';

/***************************************************************************************************
* Zone JS is required by default for Angular itself.
Expand Down

0 comments on commit 9e50d8e

Please sign in to comment.