Skip to content

Commit

Permalink
Apply feedback by @uncenter
Browse files Browse the repository at this point in the history
Signed-off-by: Raphael Höser <[email protected]>
  • Loading branch information
Snapstromegon committed Dec 19, 2023
1 parent 804470e commit 8095b27
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Plugins/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Pagination {
return false;
}

isFiltered(value) {
isIncluded(value) {
const hasInclude = "include" in this.data.pagination;
const hasExclude = "exclude" in this.data.pagination;
if (hasInclude && hasExclude) {
Expand All @@ -107,27 +107,27 @@ class Pagination {
if (hasInclude) {
let included = this.data.pagination.include;
if (Array.isArray(included)) {
return !included.includes(value);
return included.includes(value);
}
return included !== value;
return included === value;
}
if (hasExclude) {
let excluded = this.data.pagination.exclude;
if (Array.isArray(excluded)) {
return excluded.includes(value);
return !excluded.includes(value);
}
return excluded === value;
return excluded !== value;
}

// Let's keep this code for backwards compatibility to V2.
// TODO remove in 3.0
if ("filter" in this.data.pagination) {
let filtered = this.data.pagination.filter;
if (Array.isArray(filtered)) {
return filtered.indexOf(value) > -1;
return filtered.indexOf(value) === -1;
}

return filtered === value;
return filtered !== value;
}

return false;
Expand Down Expand Up @@ -189,7 +189,7 @@ class Pagination {
this.data.pagination.include ||
this.data.pagination.exclude
) {
result = result.filter((value) => !this.isFiltered(value));
result = result.filter((value) => this.isIncluded(value));
}

return result;
Expand Down

0 comments on commit 8095b27

Please sign in to comment.