DEV: Use `includes()` instead of `indexOf() >= 0` (#17553)
Missed those cases in #17541
This commit is contained in:
parent
0db6ae1e1f
commit
9028df0fda
|
@ -63,7 +63,7 @@ export default Mixin.create({
|
||||||
|
|
||||||
@discourseComputed("valid_values")
|
@discourseComputed("valid_values")
|
||||||
allowsNone(validValues) {
|
allowsNone(validValues) {
|
||||||
if (validValues && validValues.indexOf("") >= 0) {
|
if (validValues?.includes("")) {
|
||||||
return "admin.settings.none";
|
return "admin.settings.none";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -121,7 +121,7 @@ export function setIconList(iconList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isExistingIconId(id) {
|
export function isExistingIconId(id) {
|
||||||
return _iconList && _iconList.indexOf(id) >= 0;
|
return _iconList.includes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function warnIfMissing(id) {
|
function warnIfMissing(id) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default Component.extend({
|
||||||
|
|
||||||
@discourseComputed("color", "usedColors")
|
@discourseComputed("color", "usedColors")
|
||||||
isUsed(color, usedColors) {
|
isUsed(color, usedColors) {
|
||||||
return (usedColors || []).indexOf(color.toUpperCase()) >= 0;
|
return (usedColors || []).includes(color.toUpperCase());
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("isUsed")
|
@discourseComputed("isUsed")
|
||||||
|
|
|
@ -198,8 +198,8 @@ function authorizedImagesExtensions(staff, siteSettings) {
|
||||||
|
|
||||||
export function authorizesAllExtensions(staff, siteSettings) {
|
export function authorizesAllExtensions(staff, siteSettings) {
|
||||||
return (
|
return (
|
||||||
siteSettings.authorized_extensions.indexOf("*") >= 0 ||
|
siteSettings.authorized_extensions.includes("*") ||
|
||||||
(siteSettings.authorized_extensions_for_staff.indexOf("*") >= 0 && staff)
|
(siteSettings.authorized_extensions_for_staff.includes("*") && staff)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ const TopicList = RestModel.extend({
|
||||||
loadBefore(topic_ids, storeInSession) {
|
loadBefore(topic_ids, storeInSession) {
|
||||||
// refresh dupes
|
// refresh dupes
|
||||||
this.topics.removeObjects(
|
this.topics.removeObjects(
|
||||||
this.topics.filter((topic) => topic_ids.indexOf(topic.id) >= 0)
|
this.topics.filter((topic) => topic_ids.includes(topic.id))
|
||||||
);
|
);
|
||||||
|
|
||||||
const url = `${getURL("/")}${this.filter}.json?topic_ids=${topic_ids.join(
|
const url = `${getURL("/")}${this.filter}.json?topic_ids=${topic_ids.join(
|
||||||
|
|
|
@ -61,9 +61,7 @@ const Topic = RestModel.extend({
|
||||||
@discourseComputed("posters.[]")
|
@discourseComputed("posters.[]")
|
||||||
lastPoster(posters) {
|
lastPoster(posters) {
|
||||||
if (posters && posters.length > 0) {
|
if (posters && posters.length > 0) {
|
||||||
const latest = posters.filter(
|
const latest = posters.filter((p) => p.extras?.includes("latest"))[0];
|
||||||
(p) => p.extras && p.extras.indexOf("latest") >= 0
|
|
||||||
)[0];
|
|
||||||
return latest || posters.firstObject;
|
return latest || posters.firstObject;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,7 +31,7 @@ const UserAction = RestModel.extend({
|
||||||
|
|
||||||
@discourseComputed("action_type")
|
@discourseComputed("action_type")
|
||||||
descriptionKey(action) {
|
descriptionKey(action) {
|
||||||
if (action === null || UserAction.TO_SHOW.indexOf(action) >= 0) {
|
if (action === null || UserAction.TO_SHOW.includes(action)) {
|
||||||
if (this.isPM) {
|
if (this.isPM) {
|
||||||
return this.sameUser ? "sent_by_you" : "sent_by_user";
|
return this.sameUser ? "sent_by_you" : "sent_by_user";
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,7 +180,7 @@ UserAction.reopenClass({
|
||||||
const found = uniq[key];
|
const found = uniq[key];
|
||||||
if (found === void 0) {
|
if (found === void 0) {
|
||||||
let current;
|
let current;
|
||||||
if (UserAction.TO_COLLAPSE.indexOf(item.action_type) >= 0) {
|
if (UserAction.TO_COLLAPSE.includes(item.action_type)) {
|
||||||
current = UserAction.create(item);
|
current = UserAction.create(item);
|
||||||
item.switchToActing();
|
item.switchToActing();
|
||||||
current.addChild(item);
|
current.addChild(item);
|
||||||
|
@ -191,7 +191,7 @@ UserAction.reopenClass({
|
||||||
collapsed[pos] = current;
|
collapsed[pos] = current;
|
||||||
pos += 1;
|
pos += 1;
|
||||||
} else {
|
} else {
|
||||||
if (UserAction.TO_COLLAPSE.indexOf(item.action_type) >= 0) {
|
if (UserAction.TO_COLLAPSE.includes(item.action_type)) {
|
||||||
item.switchToActing();
|
item.switchToActing();
|
||||||
collapsed[found].addChild(item);
|
collapsed[found].addChild(item);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -47,7 +47,7 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
|
||||||
return function (topic_ids, storeInSession) {
|
return function (topic_ids, storeInSession) {
|
||||||
// refresh dupes
|
// refresh dupes
|
||||||
this.topics.removeObjects(
|
this.topics.removeObjects(
|
||||||
this.topics.filter((topic) => topic_ids.indexOf(topic.id) >= 0)
|
this.topics.filter((topic) => topic_ids.includes(topic.id))
|
||||||
);
|
);
|
||||||
|
|
||||||
const url = `${getURL("/")}latest.json?topic_ids=${topic_ids.join(",")}`;
|
const url = `${getURL("/")}latest.json?topic_ids=${topic_ids.join(",")}`;
|
||||||
|
|
|
@ -129,7 +129,7 @@ export default class PostCooked {
|
||||||
|
|
||||||
// this might be an attachment
|
// this might be an attachment
|
||||||
if (lc.internal && /^\/uploads\//.test(lc.url)) {
|
if (lc.internal && /^\/uploads\//.test(lc.url)) {
|
||||||
valid = href.indexOf(lc.url) >= 0;
|
valid = href.includes(lc.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match server-side behaviour for internal links with query params
|
// Match server-side behaviour for internal links with query params
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default Component.extend({
|
||||||
|
|
||||||
let tags = this.selectedTags;
|
let tags = this.selectedTags;
|
||||||
if (tags.length >= 20 && this.selectKit.filter) {
|
if (tags.length >= 20 && this.selectKit.filter) {
|
||||||
tags = tags.filter((t) => t.indexOf(this.selectKit.filter) >= 0);
|
tags = tags.filter((t) => t.includes(this.selectKit.filter));
|
||||||
} else if (tags.length >= 20) {
|
} else if (tags.length >= 20) {
|
||||||
tags = tags.slice(0, 20);
|
tags = tags.slice(0, 20);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue