mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:49:06 +08:00
REFACTOR: Remove _.range
and use ES6 instead
This commit is contained in:
parent
115b3b6921
commit
55c9c54b8b
|
@ -23,7 +23,6 @@ import Site from "discourse/models/site";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import bootbox from "bootbox";
|
import bootbox from "bootbox";
|
||||||
import { isEmpty } from "@ember/utils";
|
|
||||||
|
|
||||||
// The actions the composer can take
|
// The actions the composer can take
|
||||||
export const CREATE_TOPIC = "createTopic",
|
export const CREATE_TOPIC = "createTopic",
|
||||||
|
|
|
@ -362,7 +362,9 @@ export default RestModel.extend({
|
||||||
if (this.isMegaTopic) {
|
if (this.isMegaTopic) {
|
||||||
this.set("loadingBelow", true);
|
this.set("loadingBelow", true);
|
||||||
|
|
||||||
const fakePostIds = _.range(-1, -this.get("topic.chunk_size"), -1);
|
const fakePostIds = [
|
||||||
|
...Array(this.get("topic.chunk_size") - 1).keys()
|
||||||
|
].map(i => -i - 1);
|
||||||
postsWithPlaceholders.appending(fakePostIds);
|
postsWithPlaceholders.appending(fakePostIds);
|
||||||
|
|
||||||
return this.fetchNextWindow(
|
return this.fetchNextWindow(
|
||||||
|
|
|
@ -334,10 +334,11 @@ export default Controller.extend({
|
||||||
return EmberObject.create(options);
|
return EmberObject.create(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
_comboboxOptions(start_index, end_index) {
|
_comboboxOptions(startIndex, endIndex) {
|
||||||
return _.range(start_index, end_index).map(number => {
|
return [...Array(endIndex - startIndex).keys()].map(number => ({
|
||||||
return { value: number, name: number };
|
value: number + startIndex,
|
||||||
});
|
name: number + startIndex
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_setupPoll() {
|
_setupPoll() {
|
||||||
|
|
|
@ -521,17 +521,15 @@ export function applyDefaultHandlers(pretender) {
|
||||||
post_number: parseInt(p, 10)
|
post_number: parseInt(p, 10)
|
||||||
}));
|
}));
|
||||||
} else if (postNumber && request.queryParams.asc === "true") {
|
} else if (postNumber && request.queryParams.asc === "true") {
|
||||||
posts = _.range(postNumber + 1, postNumber + 6).map(p => ({
|
posts = [...Array(5).keys()].map(p => ({
|
||||||
id: parseInt(p, 10),
|
id: p + postNumber + 1,
|
||||||
post_number: parseInt(p, 10)
|
post_number: p + postNumber + 1
|
||||||
}));
|
}));
|
||||||
} else if (postNumber && request.queryParams.asc === "false") {
|
} else if (postNumber && request.queryParams.asc === "false") {
|
||||||
posts = _.range(postNumber - 5, postNumber)
|
posts = [...Array(5).keys()].map(p => ({
|
||||||
.reverse()
|
id: postNumber - p - 1,
|
||||||
.map(p => ({
|
post_number: postNumber - p - 1
|
||||||
id: parseInt(p, 10),
|
}));
|
||||||
post_number: parseInt(p, 10)
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response(200, { post_stream: { posts } });
|
return response(200, { post_stream: { posts } });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user