mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 12:53:42 +08:00
DEV: minor refactoring or jump-to-post (#15312)
- replaces alias by reads - drops jquery usage - autofocus should already be done; so remove custom code - uses @action
This commit is contained in:
parent
88fa8b5848
commit
666d291b24
|
@ -1,26 +1,21 @@
|
|||
import Controller from "@ember/controller";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import { alias } from "@ember/object/computed";
|
||||
import { next } from "@ember/runloop";
|
||||
import { reads } from "@ember/object/computed";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
model: null,
|
||||
postNumber: null,
|
||||
postDate: null,
|
||||
filteredPostsCount: alias("topic.postStream.filteredPostsCount"),
|
||||
filteredPostsCount: reads("topic.postStream.filteredPostsCount"),
|
||||
|
||||
onShow() {
|
||||
next(() => $("#post-jump").focus());
|
||||
},
|
||||
|
||||
actions: {
|
||||
jump() {
|
||||
if (this.postNumber) {
|
||||
this._jumpToIndex(this.filteredPostsCount, this.postNumber);
|
||||
} else if (this.postDate) {
|
||||
this._jumpToDate(this.postDate);
|
||||
}
|
||||
},
|
||||
@action
|
||||
jump() {
|
||||
if (this.postNumber) {
|
||||
this._jumpToIndex(this.filteredPostsCount, this.postNumber);
|
||||
} else if (this.postDate) {
|
||||
this._jumpToDate(this.postDate);
|
||||
}
|
||||
},
|
||||
|
||||
_jumpToIndex(postsCounts, postNumber) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user