mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: Jumping to new posts was broken
This commit is contained in:
parent
560e910c6c
commit
d08007f505
@ -1,3 +1,4 @@
|
|||||||
|
import DiscourseURL from 'discourse/lib/url';
|
||||||
import { keyDirty } from 'discourse/widgets/widget';
|
import { keyDirty } from 'discourse/widgets/widget';
|
||||||
import MountWidget from 'discourse/components/mount-widget';
|
import MountWidget from 'discourse/components/mount-widget';
|
||||||
|
|
||||||
@ -129,6 +130,17 @@ export default MountWidget.extend({
|
|||||||
$(window).bind('scroll.post-stream', debouncedScroll);
|
$(window).bind('scroll.post-stream', debouncedScroll);
|
||||||
this._scrollTriggered();
|
this._scrollTriggered();
|
||||||
|
|
||||||
|
this.appEvents.on('post-stream:posted', staged => {
|
||||||
|
const disableJumpReply = this.currentUser.get('disable_jump_reply');
|
||||||
|
|
||||||
|
this.queueRerender(() => {
|
||||||
|
if (staged && !disableJumpReply) {
|
||||||
|
const postNumber = staged.get('post_number');
|
||||||
|
DiscourseURL.jumpToPost(postNumber, { skipIfOnScreen: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.$().on('mouseenter.post-stream', 'button.widget-button', e => {
|
this.$().on('mouseenter.post-stream', 'button.widget-button', e => {
|
||||||
$('button.widget-button').removeClass('d-hover');
|
$('button.widget-button').removeClass('d-hover');
|
||||||
$(e.target).addClass('d-hover');
|
$(e.target).addClass('d-hover');
|
||||||
@ -154,6 +166,7 @@ export default MountWidget.extend({
|
|||||||
this.$().off('mouseenter.post-stream');
|
this.$().off('mouseenter.post-stream');
|
||||||
this.$().off('mouseleave.post-stream');
|
this.$().off('mouseleave.post-stream');
|
||||||
this.appEvents.off('post-stream:refresh');
|
this.appEvents.off('post-stream:refresh');
|
||||||
|
this.appEvents.off('post-stream:posted');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -263,7 +263,6 @@ export default Ember.Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
var staged = false;
|
var staged = false;
|
||||||
const disableJumpReply = Discourse.User.currentProp('disable_jump_reply');
|
|
||||||
|
|
||||||
// TODO: This should not happen in model
|
// TODO: This should not happen in model
|
||||||
const imageSizes = {};
|
const imageSizes = {};
|
||||||
@ -290,6 +289,9 @@ export default Ember.Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.appEvents.trigger('post-stream:refresh');
|
self.appEvents.trigger('post-stream:refresh');
|
||||||
|
if (result.responseJson.action === "create_post") {
|
||||||
|
self.appEvents.trigger('post:highlight', result.payload.post_number);
|
||||||
|
}
|
||||||
self.close();
|
self.close();
|
||||||
|
|
||||||
const currentUser = Discourse.User.current();
|
const currentUser = Discourse.User.current();
|
||||||
@ -299,14 +301,6 @@ export default Ember.Controller.extend({
|
|||||||
currentUser.set('reply_count', currentUser.get('reply_count') + 1);
|
currentUser.set('reply_count', currentUser.get('reply_count') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO disableJumpReply is super crude, it needs to provide some sort
|
|
||||||
// of notification to the end user
|
|
||||||
if (!composer.get('replyingToTopic') || !disableJumpReply) {
|
|
||||||
const post = result.target;
|
|
||||||
if (post && !staged) {
|
|
||||||
DiscourseURL.routeTo(post.get('url'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
composer.set('disableDrafts', false);
|
composer.set('disableDrafts', false);
|
||||||
self.appEvents.one('composer:opened', () => bootbox.alert(error));
|
self.appEvents.one('composer:opened', () => bootbox.alert(error));
|
||||||
@ -317,18 +311,10 @@ export default Ember.Controller.extend({
|
|||||||
staged = composer.get('stagedPost');
|
staged = composer.get('stagedPost');
|
||||||
}
|
}
|
||||||
|
|
||||||
Em.run.schedule('afterRender', function() {
|
this.appEvents.trigger('post-stream:posted', staged);
|
||||||
if (staged && !disableJumpReply) {
|
|
||||||
const postNumber = staged.get('post_number');
|
|
||||||
DiscourseURL.jumpToPost(postNumber, { skipIfOnScreen: true });
|
|
||||||
self.appEvents.trigger('post:highlight', postNumber);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.messageBus.pause();
|
this.messageBus.pause();
|
||||||
promise.finally(function(){
|
promise.finally(() => this.messageBus.resume());
|
||||||
self.messageBus.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
@ -363,7 +363,6 @@ export default RestModel.extend({
|
|||||||
|
|
||||||
// Commit the post we staged. Call this after a save succeeds.
|
// Commit the post we staged. Call this after a save succeeds.
|
||||||
commitPost(post) {
|
commitPost(post) {
|
||||||
|
|
||||||
if (this.get('topic.id') === post.get('topic_id')) {
|
if (this.get('topic.id') === post.get('topic_id')) {
|
||||||
if (this.get('loadedAllPosts')) {
|
if (this.get('loadedAllPosts')) {
|
||||||
this.appendPost(post);
|
this.appendPost(post);
|
||||||
|
@ -185,7 +185,7 @@ function highlight(postNumber) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
listenForViewEvent(TopicView, 'post:highlight', function(postNumber) {
|
listenForViewEvent(TopicView, 'post:highlight', postNumber => {
|
||||||
Ember.run.scheduleOnce('afterRender', null, highlight, postNumber);
|
Ember.run.scheduleOnce('afterRender', null, highlight, postNumber);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user