From 243b5756eece417e0435cea13ca90ab2a7c025f1 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 27 Mar 2017 11:23:06 -0400 Subject: [PATCH] Adds a keyboard shortcut (shift+u) for jumping back to the last read post --- app/assets/javascripts/discourse/controllers/topic.js.es6 | 4 ++++ .../javascripts/discourse/lib/keyboard-shortcuts.js.es6 | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 26f8fb941ff..32b824fc25e 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -474,6 +474,10 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { DiscourseURL.routeTo(this.get('model.lastPostUrl'), { skipIfOnScreen: false }); }, + jumpUnread() { + this._jumpToPostId(this.get('model.last_read_post_id')); + }, + selectAll() { const posts = this.get('model.postStream.posts'); const selectedPosts = this.get('selectedPosts'); diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index d393127a732..15372b27ad6 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -48,6 +48,7 @@ const bindings = { 'shift+p': {handler: 'pinUnpinTopic'}, 'shift+r': {handler: 'replyToTopic'}, 'shift+s': {click: '#topic-footer-buttons button.share', anonymous: true}, // share topic + 'shift+u': {handler: 'goToUnreadPost'}, 'shift+z shift+z': {handler: 'logout'}, 't': {postAction: 'replyAsNewTopic'}, 'u': {handler: 'goBack', anonymous: true}, @@ -117,6 +118,10 @@ export default { this._jumpTo('jumpBottom'); }, + goToUnreadPost() { + this._jumpTo('jumpUnread'); + }, + _jumpTo(direction) { if ($('.container.posts').length) { this.container.lookup('controller:topic').send(direction);