mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
REFACTOR: Remove _.first
from codebase
This commit is contained in:
@ -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);
|
||||||
|
@ -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 [];
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user