REFACTOR: Remove _.first from codebase

This commit is contained in:
Robin Ward 2020-08-31 16:41:42 -04:00
parent 55c9c54b8b
commit 66021abe41
5 changed files with 13 additions and 7 deletions

View File

@ -16,7 +16,7 @@ export function currentThemeKey() {
export function currentThemeIds() {
const themeIds = [];
const elem = _.first($(keySelector));
const elem = $(keySelector)[0];
if (elem) {
elem.content.split(",").forEach(num => {
num = parseInt(num, 10);

View File

@ -145,8 +145,12 @@ export default RestModel.extend({
**/
@discourseComputed("posts.[]", "stream.[]")
previousWindow() {
if (!this.posts) {
return [];
}
// If we can't find the last post loaded, bail
const firstPost = _.first(this.posts);
const firstPost = this.posts[0];
if (!firstPost) {
return [];
}

View File

@ -29,8 +29,9 @@ export default createPMRoute("groups", "private-messages-groups").extend({
const split = model.get("filter").split("/");
const groupName = split[split.length - 2];
this.set("groupName", groupName);
const groups = this.modelFor("user").get("groups");
const group = _.first(groups.filterBy("name", groupName));
const group = this.modelFor("user")
.get("groups")
.filterBy("name", groupName)[0];
this.controllerFor("user-private-messages").set("group", group);
},

View File

@ -23,8 +23,9 @@ export default createPMRoute("groups", "private-messages-groups").extend({
afterModel(model) {
const groupName = _.last(model.get("filter").split("/"));
this.set("groupName", groupName);
const groups = this.modelFor("user").get("groups");
const group = _.first(groups.filterBy("name", groupName));
const group = this.modelFor("user")
.get("groups")
.filterBy("name", groupName)[0];
this.controllerFor("user-private-messages").set("group", group);
},

View File

@ -267,7 +267,7 @@ QUnit.assert.present = function(actual, message) {
};
QUnit.assert.containsInstance = function(collection, klass, message) {
const result = klass.detectInstance(_.first(collection));
const result = klass.detectInstance(collection[0]);
this.pushResult({
result,
message