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() { export function currentThemeIds() {
const themeIds = []; const themeIds = [];
const elem = _.first($(keySelector)); const elem = $(keySelector)[0];
if (elem) { if (elem) {
elem.content.split(",").forEach(num => { elem.content.split(",").forEach(num => {
num = parseInt(num, 10); num = parseInt(num, 10);

View File

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

View File

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

View File

@ -23,8 +23,9 @@ export default createPMRoute("groups", "private-messages-groups").extend({
afterModel(model) { afterModel(model) {
const groupName = _.last(model.get("filter").split("/")); const groupName = _.last(model.get("filter").split("/"));
this.set("groupName", groupName); this.set("groupName", groupName);
const groups = this.modelFor("user").get("groups"); const group = this.modelFor("user")
const group = _.first(groups.filterBy("name", groupName)); .get("groups")
.filterBy("name", groupName)[0];
this.controllerFor("user-private-messages").set("group", group); 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) { QUnit.assert.containsInstance = function(collection, klass, message) {
const result = klass.detectInstance(_.first(collection)); const result = klass.detectInstance(collection[0]);
this.pushResult({ this.pushResult({
result, result,
message message