From 666d291b24bcd0c2b6dfe2852fb4dbb3b74811ef Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 15 Dec 2021 12:09:26 +0100 Subject: [PATCH] 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 --- .../discourse/app/controllers/jump-to-post.js | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/jump-to-post.js b/app/assets/javascripts/discourse/app/controllers/jump-to-post.js index dab3ced52b..968b3e78ea 100644 --- a/app/assets/javascripts/discourse/app/controllers/jump-to-post.js +++ b/app/assets/javascripts/discourse/app/controllers/jump-to-post.js @@ -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) {