REFACTOR: Remove `_.first` from codebase

REFACTOR: Remove _.first from codebase

diff --git a/app/assets/javascripts/discourse/app/lib/theme-selector.js b/app/assets/javascripts/discourse/app/lib/theme-selector.js
index 82d838f..4768616 100644
--- a/app/assets/javascripts/discourse/app/lib/theme-selector.js
+++ b/app/assets/javascripts/discourse/app/lib/theme-selector.js
@@ -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);
diff --git a/app/assets/javascripts/discourse/app/models/post-stream.js b/app/assets/javascripts/discourse/app/models/post-stream.js
index c36cf9a..4a9a245 100644
--- a/app/assets/javascripts/discourse/app/models/post-stream.js
+++ b/app/assets/javascripts/discourse/app/models/post-stream.js
@@ -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 [];
     }
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-group-archive.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-group-archive.js
index 74ad2f5..5d84562 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-group-archive.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages-group-archive.js
@@ -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);
   },
 
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js
index f3e606a..f4e9b6f 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js
@@ -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);
   },
 
diff --git a/test/javascripts/helpers/qunit-helpers.js b/test/javascripts/helpers/qunit-helpers.js
index 1b1446a..e640473 100644
--- a/test/javascripts/helpers/qunit-helpers.js
+++ b/test/javascripts/helpers/qunit-helpers.js
@@ -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

GitHub sha: 66021abe

This commit appears in #10566 which was merged by eviltrout.